updated script code