Optimization of error handling