Changed syntax of if statement to be DRYer.