fixed getLastShaIndex logic error;