encoder and decoder implemented