change encode method