Modify the encode subroutine.