updated encoder and decoder