semi-working implementation of the huffman algorithm