Changed method decode to encode