The Trump administration announced last week it will terminate the Flores settlement agreement, a 1997 court decree that has prevented U.S. officials from detaining migrant families and unaccompanied minors for more than 20 days. Media coverage predictably—and inaccurately—warned of “indefinite detention” for families and children caught crossing the southwest border.

But ending the settlement was the right call. More than any other single policy, it has created a magnet for illegal immigration, essentially guaranteeing entry to unaccompanied minors and any adult who crosses the Rio Grande with a child.

The 1997 settlement lets smugglers use children as ‘passports’ and further enriches drug cartels.

The result: hundreds of thousands of minors apprehended, then released to parents or other relatives living in the U.S., and a massive surge in the number of family units crossing the border to claim asylum—from fewer than 15,000 in 2013 to nearly half a million so far this year, a nearly 30-fold increase, according to U.S. Customs and Border Protection.

Nearly all these families—most of which are from Guatemala, Honduras or El Salvador—have been released pending the outcome of their immigration hearings, a process that can take years. In the meantime, those who are approved to seek asylum are free to live and work—legally—in the U.S. Almost none have been deported.

The administration has now published a new regulation that will set standards for the detention and treatment of unaccompanied minors and families, including a policy to keep families together in federal custody. It’s the latest attempt to work around a woefully inadequate underlying body of immigration and asylum law, which Congress has refused to reform. These archaic laws are what’s driving the migrant crisis.

The history of the Flores case helps explain why. In 1997 the Clinton administration agreed to settle a suit filed nine years earlier by immigration advocates on behalf of a group of Central American teenagers in federal custody. The agreement laid out nationwide detention standards for unaccompanied alien children, as well as the timing and terms of their release. But it said nothing about families.

Fast forward to 2015, when the U.S. faced unprecedented numbers of families and unaccompanied minors crossing the border and claiming asylum. President Obama’s initial response was to detain family units for the duration of their cases, and his administration established family detention centers specifically for this purpose—all of which are still in use.

That year, a federal district court judge ruled that family detention violated the terms of the Flores settlement, and reinterpreted the agreement to apply to families as well as unaccompanied minors. The judge also ruled that family units and unaccompanied minors could not be detained for more than 20 days—an arbitrary threshold that was never part of the original Flores agreement.

The Ninth U.S. Circuit Court of Appeals upheld this ruling in 2016, presenting the Obama administration with a choice: Either separate parents from children at the border to detain the parents and criminally prosecute them, or release them. Mr. Obama opted for catch and release. The Trump administration briefly tried family separation, only to abandon it last year amid a public outcry.

Catch and release created a powerful incentive for families to cross the border illegally and make specious asylum claims. It also created an incentive for smugglers to offer huge discounts to anyone traveling with a child. Instead of attempting to evade Border Patrol, as they do with single adults, smugglers could simply bring migrant families up to the south side of the Rio Grande and tell them when to cross. Families were told to find a Border Patrol agent, turn themselves in, and not worry—they’d soon be released.

They were—by the tens of thousands. As a result, children became “passports” into the U.S., and the number of families crossing the border surged, after dipping sharply in 2017. Smuggling organizations now advertise discounted family rates and are collecting billions of dollars. So are the drug cartels that control vast swaths of northern Mexico and charge a toll for every migrant who crosses the Rio Grande from cartel-controlled territory.

All this puts minors at risk. U.S. officials have encountered thousands of “fake families” at the border, and even instances in which children have been “recycled”—crossing multiple times with different unrelated adults posing as the parent.

By sending the message that only legitimate asylum seekers will be released into the U.S., the administration hopes to deter aliens without valid asylum claims from making the dangerous journey in the first place.

What about detained unaccompanied minors? They still must be released to a sponsor in the U.S., usually a parent or other relative. Once released, a date is set for their appearance before an immigration judge. But the vast majority of sponsors are themselves in the country illegally, so of course the minors rarely show up for their hearing. They simply disappear into the immigration underground. The number of minors ordered deported after failing to show up at their hearings went from 519 in 2010 to more than 6,700 last year.

All of this is a direct result of outdated federal laws and congressional inaction. Much more can be done to remove the incentives for parents to pay smugglers and cartels to transport their children to the U.S. border—for example, U.S. authorities could swiftly deport the parents behind this scheme along with their children. But scrapping the Flores settlement is a wise and necessary first step.