this loop is very important to make sure the caching still works even when haplotypes have different lengths. You can't comment it out.