update apply function