#65 improve error detection