correctly handling callback errors