Fixed monstrous bug

Had been using the wrong variable to reference the one in the for the for-each loop