fix the logic for detecting process failures