Fix error detection