bug fix typo on function encode