encoding and decoding working