fix access out of bounds

I want the loop to do the comparison first since it will fail most of the time.
The 2 * !j < sublen check will only fail when a match is found,
but since it also protects the comparisons from out of bounds accesses,
it has to be done after the incremantation.