Replace if/else with a cleaner switch statement