rewrite document