Breaking out a loop by counting button presses