rewrite scipt