used a switch statement instead of if