local optimization on autogenerated script