Use proper logic in if statement