Changed the logic of error reporting