Twice now this year, federal health officials have warned Americans not to eat any romaine lettuce at all, and asked stores to throw away all their supplies.

It wasn’t because all the romaine lettuce in the country was contaminated. It was because there was no good way to figure out quickly where the contaminated lettuce was coming from. When people started dying from E. coli infections last spring, the Food and Drug Administration and the Centers for Disease Control and Prevention decided the safest bet was just to tell people to stop eating it.

It took weeks to narrow down the spring outbreak to Yuma, Arizona. It took several days to trace this fall’s outbreak to central California. In a best-case scenario, the moment someone got sick, it would have been possible to figure out what they ate and where it came from, so that specific farm or processor or distributor could be shut down.

Instead, it takes days to even detect an outbreak, more days to ask people what they ate recently to try to come up with a food that all the sick people had in common and then sometimes weeks to find out a common source for that food.

“It is very difficult and very time-consuming,” said Dr. Laura Gieraltowski, who leads the CDC’s foodborne outbreak response team. “Grocery stores might not keep the box that has the labels from the distribution center was or where the grower was.” And right now, without that box, many stores don’t have a record of where the food product came from.

“We are in a challenging position in that we have not been able to fully isolate it to one specific grower or region to issue a mandatory recall,” FDA commissioner Dr. Scott Gottlieb told NBC News last week.

It’s a frustrating and inefficient process, and now the FDA is looking to a mega-retailer to help solve the problem: Walmart.

The FDA has hired Walmart’s vice president of food safety, Frank Yiannas, as deputy commissioner for foods and veterinary medicine. Gottlieb hopes Yiannas can help persuade the U.S. food industry to adopt a computerized system that keeps track of each head of lettuce, or box of mangoes, or package of chicken parts, along each step of the way from farm to store or restaurant.

“One of his specific areas of expertise is the development of blockchain technology for track and trace,” Gottlieb said.

Blockchain is a shorthand term for a way of keeping accurate records of transactions that is timestamped and difficult to alter. Used in food distribution, it would be a secure way to track food as it is harvested, processed, packaged, distributed and sold.

Gottlieb sees blockchain as a useful tool to help tame the free-for-all system that gets many types of food to the U.S. table now.

“We’d like to link the outbreak back to a specific grower, a specific farm, a specific distributor,” Gottlieb said.

“We hope to be able to roll out some of those same technologies in the coming years…so that when we go out with a warning, it’s not a blanket warning not to eat romaine lettuce.”

Walmart itself is still trying to roll out the technology, said company spokeswoman Molly Blakeman. The first step is getting all its food suppliers to buy into IBM’s computer technology.

“All fresh leafy greens suppliers are expected to be able to trace their products back to farm(s) (by production lot) in seconds — not days. To do this, suppliers will be required to capture digital, end-to-end traceability event information using the IBM Food Trust network,” Walmart said in a letter to suppliers last September.

The company doesn’t expect its suppliers to comply before next year. Some still use paper records.

“Some of them are not digitized yet. They would need to get that technology,” Blakeman said. “We have worked with IBM to make it affordable.” The company is trying to negotiate a sliding scale for the farms and distributors that provide fresh produce, so that they pay according to their size.

But if it works, products would be labeled and scanned through every step of the journey from farm to processor to packaging and delivery, so that when there was an outbreak of foodborne illness, health officials would be saved days or even weeks of traceback work, and could get more specific warnings out to consumers faster.

That might mean having a choice of safe romaine lettuce during a recall. And it will save stores and distributors from the huge losses they often suffer when they have to pull a product off the shelves wholesale.

As a start, the FDA worked out an agreement for producers to start labeling romaine lettuce. It’s a voluntary process now, the United Fresh Produce Association and Produce Marketing Association say in a joint statement. “Your records can eliminate your company from a recall,” it tells members.

What blockchain will not do is stop foodborne outbreaks from happening in the first place.

The FDA is under pressure from consumer groups for delaying a rule that would have required growers to test their irrigation for contamination. The spring outbreak of E. coli that killed five people and made more than 200 more sick was traced to romaine lettuce grown in Yuma, Arizona. It was eventually blamed on contaminated canal water.

Similarly, an outbreak in 2006 was traced to spinach grown in California that may have been contaminated by manure from wild pigs or, perhaps, nearby cattle farms.

The 2011 Food Safety Modernization Act directed FDA to step up rule for food safety and the agency issued a final rule in 2015 that gave growers until early this year, rolling into 2022 to test water quality. But the FDA has delayed implementing the rule.

“The Trump Administration is willing to put Americans’ health at risk to appease Big Ag and food companies.” said George Kimbrell, legal director at the Center for Food Safety. “This shameful delay could literally cost Americans their lives.”

The Center for Food Safety and the Center for Science in the Public Interest want the FDA to speed up these rules, not delay them.

“Americans deserve to know that their produce wasn’t grown or rinsed in water contaminated with animal feces,” said CSPI deputy director for legislative affairs Sarah Sorscher.

Gottlieb denies that his agency delayed the rule for political reasons.

“We are fully committed to implementing that rule,” he said. “There is nothing that I have withdrawn or delayed that I believe would have impacted food safety,” he added, saying the FDA was moving “full steam ahead” on food safety.

But they said the rule was “very difficult to implement.”

“It’s not that we have made a political decision at all to delay that,” he said.

Contaminated food is an extremely common problem. The CDC estimates that germs in food make 48 million Americans sick every year — that’s one out of six people. About 128,000 are made sick enough to be hospitalized, and 3,000 die. The germs to blame include listeria, salmonella, E. coli and cyclospora.