Fixed process_result with new error detection