Refactored use of if/else/elsif