rewrite extract script