setdefault instead of defaultdict here