fix bug in error handler