fix encoding/decoding