fixed an issue in encoding