Added error handling for callbacks