So as to not confuse anyone, my post had a mistake. The change should be added before the loop at around line 97 as someone else had mentioned.