c++ style
c++ : pass arg by const ref
range based for loops + code cleanup