[Update] encoding function