Updated for loops to be ranged for loops