bug fix in script generation