updated from x[i:] to x[i:end]