small bug fix for error handling