code rewrite p.3