A federal judge has struck down an Alabama law requiring more scrutiny for minors who seek an abortion without parental consent.

U.S. Magistrate Judge Susan Russ Walker said that the law governing judicial bypass requests unconstitutionally imposes an undue burden on a minor who seeks an abortion. She said the law violates the minor’s confidentiality by possibly bringing other people from her life into the process, the Associated Press reports.

The State of Alabama had argued the law would allow a meaningful inquiry to judge the minor’s maturity while providing a “confidential, and expeditious option for a teenager who seeks an abortion without parental consent.” Other backers of the law said it helped give guidance to the minor. State law requires minors who can’t secure parental consent for abortion to seek court permission.

The 2014 law modified the process to allow a judge to appoint a guardian “for the interests of the unborn child.” The law allows the local district attorney to call witnesses and question the girl to determine her maturity level. If the minor’s parents or guardians learn of the hearing they may also be involved.

The American Civil Liberties Union of Alabama had filed the lawsuit in 2014 on behalf of the Montgomery abortion clinic Reproductive Health Services.

Judge Walker cited the case of a 12-year-old pregnant girl who had been raped by a relative. She was 13 weeks pregnant when she went before a family court judge, who approved the abortion on June 27. The district attorney appealed the decision on the grounds the fifth grader was not mature enough to make an informed decision. On July 12 the Alabama Court of Civil Appeals ruled in the girl’s favor.

The judge said that a minor seeking permission for abortion could face both a lawyer appointed for the unborn baby and the chief prosecutor in her county, who is “empowered by the act to represent the state's public policy to protect unborn life, and backed by substantial state resources.”

The Alabama attorney general’s office said it is reviewing the decision.