removed defaultdict because I wasnt using it.