How is the input wired ?
You are checking for HIGH on the input so I assume that the switch takes the input HIGH. However, what state is it in when the switch is not closed ? Do you have a pulldown resistor in place to hold the input LOW except when the switch is used or is it floating at an uncertain voltage ?
Consider using INPUT_PULLUP in the pinMode() to turn on the built in pullup resistor, change the circuit to take the input LOW when the switch is closed and change the program logic to match.