The use of medication to treat attention deficit/hyperactivity disorder (ADHD) in children remains controversial: while the medications can treat symptoms of the disorder in the short term, there’s little data showing that they benefit kids — especially in school — in the long run.

Now a new study based on data from large national databases tracking medication use and standardized test performance in students in Iceland suggests that earlier use of ADHD medication can lead to smaller declines in grades — at least in math and especially in girls. “Our main finding was that early rather than late start of drug treatment for ADHD may help avert declining academic performance in these children,” says the study’s lead author Helga Zoega, a postdoctoral student at Mount Sinai School of Medicine in New York.

The study, which was published in Pediatrics, used data collected on nearly 12,000 Icelandic children born between 1994 and 1996. It examined the kids’ prescription records and their standardized test scores in 4th and 7th grades. The study included all Icelandic children born in those years who registered for school and took both tests, including about 1,000 students who received prescriptions for ADHD medication at some point during the study period.

In Iceland, a diagnosis of ADHD must be verified before payments for medication are reimbursed, so any child having a prescription for ADHD drugs — including Adderall (amphetamine), Ritalin (methylphenidate) and Strattera (atomoxetine) — in the database would have had a diagnosis. Ritalin was the most commonly used drug. (One of the study’s 10 authors reported unrelated consultancy with pharmaceutical companies; the rest did not have affiliations with drug companies.)

All the students in the study started medication after their fourth grade test, when they were around age 9. The effects of early treatment were most dramatic for girls, particularly in math. Girls who started ADHD treatment within a year after the 4th-grade testing period were nearly three times less likely to show a future decline in math performance, compared with those starting later, 25 to 36 months after the 4th-grade tests. For boys, the chances of avoiding a decline in math achievement were 40% greater if they started medication early.

“This study significantly adds to previous research,” says Joshua Langberg, co-director of the Center for ADHD Research, Education, and Service at Virginia Commonwealth University, who was not associated with this research but recently reviewed the data on this question. He added, “This is certainly a unique and important finding, but it is important to clarify that children with ADHD on medication still declined,” meaning that medication alone does not solve the problem.

Previous research has suggested that there is a measurable positive effect of medication on test performance over time, particularly in math. But as Langberg and the co-authors of his review paper note, “[T]he magnitude of these improvements is small and the clinical or educational significance is questionable. Evidence for long-term improvements in school grades and grade retention is less compelling.”

It’s not clear in the current study why earlier treatment was associated with smaller declines in academic performance. It’s possible that children starting medication earlier are somehow different from those who start later. However, says Zoega, “In most cases, you expect that children who are detected earlier might be detected because they have more obvious symptoms. But this is the group that declined the least academically. It strengthens our results, if anything.”

It’s also not clear why girls benefited more in this study. Zoega notes that it could just be a random variation in the data. Alternatively, it may be linked to the fact that girls with ADHD tend to have more symptoms of inattention and fewer related to hyperactivity, compared with boys. The inattentiveness might be better helped by medication, which could in turn contribute more to improving school performance.

Unfortunately for parents, says Langberg, the evidence to date doesn’t clarify the right choice for families considering using the drugs. “Decisions about medication are best made on an individual, family to family basis,” he says. “What is right for one family may not be right for another family. … It is important to note that there is great variability in how children respond to medication, and while this research and other studies are very important, they don’t tell us how a particular individual child will respond.”

Indeed, if we’ve learned anything from the widely variable results of studies on antidepressants, stimulants and other types of mental-health medications, it is that a drug that works miracles for one person can cause great harm in another. While this study suggests that early medication may be especially helpful for girls with ADHD struggling in math, we still don’t know the best way to guide parents overall in finding the best help for their kids with attention problems.

Maia Szalavitz is a health writer for TIME.com. Find her on Twitter at @maiasz. You can also continue the discussion on TIME Healthland’s Facebook page and on Twitter at @TIMEHealthland.