Another improvement for error handling logic