remove unused local vars
simplify logical statement