working on rewrite