add decode for encode