improve c++ 11 for loops

use const references to map key-value pairs