fixing script bugs