Here, and below, is another case of the necessity to iterate this code over all the indices, and backward.

The good news is that once you have implemented this iteration, you might well have fixed bugs in the case of very ill-conditioned design, for which we have noticed poor behavior of the algorithm, but were not able to diagnose the problem. Good job!