huffman encoding optimised