first pass - encode/decode