wrapped callbacks in a function