fixed encode bug