fixed a bug in failure checking