encode/decode problem - trying to fix it