simplified the code by pre-checking the failures and thus constructing a smaller set of "node" to check