refactored if/else construct