corrected iterative procedure to correctly designate links to sections