If you’ve ever had a kidney stone, you surely remember it. The pain can be unbearable, coming in waves until the tiny stone passes through your urinary plumbing and out of the body. For many, kidney stones aren’t a one-time thing: in about half of people who have had one, another appears within seven years without preventive measures.

Preventing kidney stones isn’t complicated, but it does take some determination.

Kidney stones form when certain chemicals become concentrated enough in the urine to form crystals. The crystals grow into larger masses (stones), which can make their way through the urinary tract. If the stone gets stuck somewhere and blocks the flow of urine, it causes pain.

Most stones occur when calcium combines with oxalate. Stones can also form from uric acid, which is a byproduct of protein metabolism.

How to avoid kidney stones

Here are the five ways to help prevent kidney stones:

Drink plenty of water: Drinking extra water dilutes the substances in urine that lead to stones. Strive to drink enough fluids to pass 2 liters of urine a day, which is roughly eight standard 8-ounce cups. It may help to include some citrus beverages, like lemonade and orange juice. The citrate in these beverages helps block stone formation.

Eat calcium rich foods: Dietary calcium binds to oxalate in your intestines and thereby decreases the amount of oxalate that gets absorbed into the bloodstream and then excreted by the kidney. This lowers the concentration of oxalate in the urine, so there is less chance it can bind to urinary calcium. That leads to decreased risk of kidney stones.

Reduce sodium: A high-sodium diet can trigger kidney stones because it increases the amount of calcium in your urine. So, a low-sodium diet is recommended for the stone prone. Current guidelines suggest limiting total daily sodium intake to 2,300 mg. If sodium has contributed to kidney stones in the past, try to reduce your daily intake to 1,500 mg. This will also be good for your blood pressure and heart.

Limit animal protein: Eating too much animal protein, such as red meat, poultry, eggs, and seafood, boosts the level of uric acid and could lead to kidney stones. A high-protein diet also reduces levels of urinary citrate, the chemical in urine that helps prevent stones from forming. If you’re prone to stones, limit your daily meat intake to a quantity that is no bigger than a pack of playing cards. This is also a heart-healthy portion.

Avoid stone-forming foods: Beets, chocolate, spinach, rhubarb, tea, and most nuts are rich in oxalate, which can contribute to kidney stones. If you suffer from stones, your doctor may advise you to avoid these foods or to consume them in smaller amounts.

For everyone else, particular foods and drinks are unlikely to trigger kidney stones unless consumed in extremely high amounts. Some studies have shown that people who take high doses of vitamin C in the form of supplements are at slightly higher risk of kidney stones. That may be because the body converts vitamin C into oxalate.