using switch instead of if statement