rename a variable and refactor the if condition