removed calling rewrite twice