fixed error caused by incorrect start index