A switch does not go from 1 to 0 and 0 to 1, it bounces causing the Arduino to see 01010001010011111.
Between the ill placed }} at the end of the sketch, add a delay (50 to 200 should do fine). This will cause the Arduino to wait for the switch to settle on a value.