added general error handling