fixed startIndex issue