Refactored and removed redundant 'if'