changing defaultdict to dict