fixed undefined bug in script generation