fix some index error issue in AutoScript