Fix nested loops causing stack overflow