bug fix in error handler