improve error detection