changed some script and fixed bugs