Eating onions and garlic regularly may give you a wide array of health benefits, from preventing cancer and heart disease to treating infections, according to the Linus Pauling Institute. But if you let your excitement about these pungent vegetables’ benefits cause you to overindulge in them, you may suffer from some digestive problems. The key to enjoying onions and garlic is to eat them in moderation.

You may experience gas and the flatulence associated with it from eating onions and garlic, says the Linus Pauling Institute, and eating raw onions and garlic may lead to more gas than eating cooked onions and garlic. The University of Maryland Medical Center says that you may feel bloated when you’re suffering from gas after eating garlic and other vegetables in the same family, such as onions. Raw garlic and onions contain lots of fiber that can cause gas, and onions contain a natural type of sugar called fructose that causes gas, according to ClevelandClinic.com, which recommends discussing your diet with your doctor, since the amount of gas produced by foods varies from person to person.

Both onions and garlic may give you diarrhea if you eat too much of them, the Linus Pauling Institute says. If you eat foods that upset your digestive system, you may experience diarrhea that lasts between two and three days, reports ClevelandClinic.com, which recommends avoiding raw foods if you’re suffering from diarrhea. Choosing foods that don’t contain much fiber is best to get over diarrhea, and eating small portions of food is also a good idea while your digestive system is recovering from diarrhea.

You may suffer digestive problems from eating large quantities of onions, so be creative about ways you can include onions in your diet regularly without eating lots of onions all at once. The University of Maryland Medical Center advises eating garlic in moderation to avoid side effects like digestive problems, and recommends eating between two and four fresh garlic cloves per day, chopping them before cooking them.