rewrite code