implemented new rewrite method
added initial implementation of roundtripping for new rewrite method