fixed small bug in error handler