Slightly more elegant way to iterate over a dict