Encoding and decoding functions now work