added check if callback is a function