Added commentary to the loop

Described the purpose of several key lines in the code