working decoder/encoder