Fixed a bug when encoding is undefined