more complete error handling