finish rewrite