micro-optimization nit: use iteritems()