Encode bug fixed