remove dead code and change order