fix the bug of encoding