replace encode behavior