Bug fix

Encode bug fixed