start of rewrite