added slice, renamed encode/decode