improved the if statement