Adding the error handling