Refactored the if statement to make it a little neater