change to encode-decode method