changed iteritems to items() in set_conditions