changed optimize_script