adding error handling in callbacks