01: Use each_with_object in frequencies
01: Use += instead count(element) in frequencies

Do not use count(element), but instead increase with one on each occurrence.