code rewrite