Refactored if clause