added detection for failure cases