rewrote error reporting