added error handler to catch async errors