Improved script code.