Had to put the switch within the loop.