Join equivalent `if` commands
Remove unused variable
Rename equivalent variables