Use dict.iteritems instead of dict.items