added assertion to ensure a callback is a function (and not undefined)