begin rewrite