move encoding and decoding to own modules