simplified frequencies a lot by using initial hash values. also switched map for each.