Patched the encoding and length error