variable length encoding mostly working