added error handling for tasks