Add pretreatment function