use range-based foreach (C++11) for improved readability
replace another raw loop with an algorithm per Sean Parent