fixed issue with the error handling