Working version of hoffman decoder