Shouldn't this be `index + 1 < offsets.length`?