finially fixed the encode/decode path