how to rewrite a script