I am now creating the defaultdict in the function and returning it, instead of creating it in main and passing to the function.