rewrite merge