fix encode