use keys check instead of in...defaultdict, may be unnecessary