fixed error handler bug