total rewrite