add functional decoder and encoder