Simplify error detection logic.