making use of C++11's for-each loop to increase readibility