Refactored If statement