working on rewriter