Changed uses of old looping style to range-based loops