refactored elsif pattern