fixed script generation bug