Can you tell me more about the better way to connect it you said ?
Have a look at at the button in your pic- you'll see the left hand connection goes to 5V. The right side goes both to the data pin and to ground through the resistor. That's what known as a pull-down
resistor, and when the button isn't pushed it makes sure the data pin is forced to a known state, ie ground, 0V.
When the button is pushed, left and right get connected, and so the data pin is now connected to 5V thru the switch and to 0V through the resistor. The 5V side has no resistor so it wins that battle and the pin sees 5V.
BUT if you have a look at this example
you'll see the Arduino has pull-up
resistors built in so if you code like in that example, you don't have to mess around with external resistors.
The logic changes though: the way you have it, the data pin is at 0V usually and 5V when pressed; with a pull-up
it's at 5V usually and 0V when pressed. So your coding has to be reversed to take acount of what was on is now off, and what was off is now on.
Pull-ups are seen as being better, and this approach is called active-low, meaning voltage goes low when you activate the switch.