finished the rewrite