code rewrite p.1