Changed loop to range based C++11

Changed the for loop to an easier to read C++11 range based for loop.