replace if/else with switch