code rewrite p.2