Use dict.items instead of dict.iteritems for py3 compatibility