fix error detection