small refactoring in script generation