implement huffman methods