Improve error detection