Check length before doing an i+1