(CNN) – They’re used to treat infections and most often prescribed when a patient is allergic to penicillin.

But a new study published in the medical journal BMJ suggests women who were prescribed macrolides during the first three months of pregnancy had an increased risk of birth defects — compared to those who were prescribed penicillin.

The study analyzed data from more than 104,600 children born in the UK between 1990 and 2016. Their mothers were either prescribed penicillin or macrolides.

The study found that prescribing macrolides — which include erythromycin and clarithromycin – and azithromycin to pregnant women during the first trimester increased the risk of major malformations to 28 of 1,000 births — compared 18 per 1,000 births with penicillin.

Specifically — the risk of cardiac malformations was higher — the study did not find a link between macrolides and neurodevelopmental disorders.

And there was also no associated risk between birth defects and macrolides prescribed before conception.

An author of the study says based on the findings — pregnant women and their doctors should find an alternative antibiotic depending on the type of infection.

A study author also cautions about risks of not taking antibiotics at all, saying infection itself can be really damaging to the unborn baby as well.