update in apply function