Refactored if/else with case statements