Setting up the loop and switches