fix incorrect increment of stopIndex