Refactor if statement for brevity