Use items() instead of iteritems() for Python 3 compatibility