switch to using defaultdict