internal rewrite