Challenge3: implemented non functional encode/decode method