better fix for the error handler, making it an exit handler