making more use of C++11's for-each ability