added encode/decode