Check if callback exists and is a function before calling it