rewrite scripts helper