Changed to using C++11 for range