finish the model rewriter