fixed error detection