Urinary tract infections have been treated with cranberry juice for decades, but now researchers know exactly why the tart drink is so effective.

Cranberry juice and capsules have long been popular antidotes to common bacterial infections, but researchers were never quite sure why it worked, Fox News reported. Now they believe that a compound found in berries like cranberries actually prevents the bacteria from attaching to the tissue of the urinary tract. The compound is especially effective for women facing urinary tract infections, the report said.

“What this is doing is solidifying what has been folklore for quite some time,” Dr. Deborah Wing, a researcher of urinary tract infections at the University of California, Irvine, told Reuters Health.

“Finally, the science is catching up to what our mothers have been telling us for so many decades,” she added.

The new analysis looked at 10 earlier studies of roughly 1,500 people, mostly women, who took either cranberry products or cranberry-free placebos. Those assigned the cranberry products had 35 percent fewer urinary tract infections, the research team reported in the Archives of Internal Medicine. Women with a history of multiple infections saw their risk of infection drop 47 percent, the study found.

There is still not enough data to know what form of cranberries is most effective for preventing and treating urinary tract infections, Wing noted. Researchers noted that they are looking at the results with caution.

“Is (cranberry) the natural cure-all for urinary tract infections? Of course not,” Bill Gurley, a pharmaceutical researcher who studied dietary interventions at the University of Arkansas for Medical Sciences in Little Rock, told Reuters.