script+optimize bug fix