first version of the rewrite