add encoder and docoder code