Fixed the issue with the loop accessing all the gameObjects.