Added encoding procedure.