Change encode function.