finish encode/decode functions. ready to use