Final Submit
update encode function