Kept at it with fixing up next index calculation