change dicts to defaultdicts