implemented first optimization (j//2)+1

If i is less than j//2 + 1, shorten the range so that i  = j//2+1