Add error handling routine