simplify and remove dead code