use forEach(f(k,v)) to be more concise and potentially more efficient