improved error detection