Earlier this month, the Associated Press reported that one of the results of the Trump administration’s family-separation program is going to be permanent legal separation in some cases. The AP reported that in the past, separated children in federal or state government care were adopted by American families, frequently without any input or participation from their deported parents. The speed with which children in state care can be permanently separated from their parents, however, isn’t Donald Trump’s doing, and it affects many more children than those caught up in this latest crackdown on undocumented immigrants. For 20 years, federal law has encouraged state child-protection agencies and courts to put hard time limits on family-reunification efforts. The result is that many parents who are good candidates to care for their children nevertheless end up with their legal rights terminated.

This state of affairs has its roots in the child-protection systems of the 1970s and ’80s. Back then, there was widespread criticism that states were letting children languish in impermanent foster placements, including group homes, and that biological parents who had committed serious abuse were given too many chances to get their children back. In 1997, when the federal government acted to create uniformity in state child-protection systems, the number of children in state custody had nearly doubled over the preceding 15 years, while adoptions had barely increased. That year, President Bill Clinton signed the Adoption and Safe Families Act, which created financial incentives for states to streamline the process for termination of parental rights. Since then, every state has adopted laws that create a timeline of roughly two years for cases where children are placed in state care.

As a lawyer who represents children and parents in child-protection proceedings, I can see the logic in the 1997 reforms: Some parents are simply too lost to addiction, long prison sentences, or intractable mental illness to be able to get their kids back. For children in such circumstances, sooner is definitely better.

But the legal deadlines also create perverse incentives. Courts and state agencies are pressured to terminate parents’ rights even if an adoptive family has not been identified and even if the parents might soon be ready to take their kids home. Meanwhile, black and Hispanic children, who make up a disproportionate share of children in state care, remain less likely to be adopted than white children. Further, recent research suggests that for older children, children with special needs, and others less likely to be adopted, the maintenance of biological relationships is more important than the relatively abstract permanence that comes from a quick end to court proceedings.

Our child-protection system is designed to show efficiency through superficial measures without a great concern for long-term outcomes.

Addiction provides the most common example of how these time limits can go wrong. Parents who have had their children removed because of alcohol or drug addiction routinely take between six months and a year to engage with counseling and begin to get clean. It’s not uncommon for them to suffer at least one relapse. But judges frequently deem parents’ periods of sobriety immediately before trial—even for six or eight months—insufficient to prove long-term rehabilitation. And neither judges nor child-protection agencies are inclined to imperil federal grants to give a parent the opportunity to demonstrate a full year of clean living. I have seen more decisions than I can count that employ some version of this reasoning, from a 2016 case where the mother had been drug-free for six months: “[The mother’s] current sobriety is too fragile, too untested, and too unreliable to reasonably permit the inference that she has actually developed the internal resources that will ensure she will put the needs of [her children] above her own needs.”

State child welfare agencies also face budget pressures that discourage them from pursuing reunification with suitable parents where the costs will be high because the parent is out of state or abroad. Even when a parent is separated from a child not by his own bad conduct but by logistical barriers, agencies simply shrug. In one case I handled, a baby was born in Connecticut and the father was in Nigeria and couldn’t get a visa to come get his child. The child welfare agency refused to contact the State Department to explain why the father should be granted a visa and even declined to spend money to facilitate Skype contact between the father and his baby. Later, when it appeared that a visa would be granted, the trial judge refused to postpone a trial on termination of the father’s parental rights. In another case, a father was in Puerto Rico and had never met his child in Connecticut. The state agency offered to fly him up for a visit on a certain weekend, and when he said that he couldn’t take that particular weekend off because he would lose his job, the agency did not offer any alternative date but instead argued that it showed he was not truly committed to caring for his daughter.

Our child-protection system is designed to show efficiency through superficial measures without a great concern for long-term outcomes. Deported parents are simply the most salient example of a much broader class of cases—practically all of which involve poor families and families of color—where the costs and complications of reunification are prioritized over the best interests of families.

Recent thinking among child-protection lawyers and scholars has recognized that the pendulum may have swung too far from parents’ rights toward quick adoptions and that this isn’t even good for many children. Studies show that when children are old enough to know their biological parents at the time they’re removed, they tend to want to maintain a relationship with them, even if they’re never reunified. Unfortunately, child welfare laws haven’t caught up to the state of experts’ understanding. Most states make adoption one of the most permanent legal processes on the books: Once it occurs, even a valid appeal of the termination of a biological parent’s rights can’t reverse it. Likewise, most states don’t allow child-protection judges to make post-adoption orders to maintain contact between children and their birth parents.

While a change at the federal level to relax the strict adoption timelines seems unlikely, states can and should work harder to reunify parents and children and to maintain contact between children and their birth parents even after parental rights have been terminated. Child welfare agencies also need well-funded, independent oversight, and parents and children need well-resourced lawyers to make sure that the agencies aren’t letting the pressure of federal timelines push them toward the cheapest or most obvious resolutions, instead of those that are actually best for families. A handful of high-profile cases, like the case of Felipe Montes in North Carolina, have shown that a parent’s deportation need not be an insurmountable barrier to reunification, but the local child-protection agency has to be willing to go outside its comfort zone and work with foreign governments and U.S. immigration authorities to make it happen. But for this to happen, state legislators—and the voters who choose them—must recognize that supporting children requires good funding and responsible management for the local agencies that have the greatest impact on those people’s lives.