fix error handler bug