Reorder checks in if statement