added kwargs.iteritems()
reordered defs