fix error handler