Using items instead of iteritems on dictionary for python 3 compatibility