Replaced if/else with switch statement