fixed bug when setting startIndex to > 0