Changed dict.items() to dict.iteritems()