Changed the main to a switch structure