Providing shelter to migrant children who enter the United States is a multibillion-dollar business.

The Health and Human Services Department (HHS), through the Office of Refugee Resettlement, has awarded nearly $5 billion in grants over the past 15 years through the unaccompanied alien children program, according to government data. Congress’s 2018 omnibus bill provides for $1.3 billion for the program.

These facilities are likely better than one alternative we’ve seen in recent days: kids piled up in concrete cells, cages, and temporary facilities operated by border officials. But in light of the family separation crisis at the border that resulted in 2,300 children being split from their parents as they tried to cross into the US, the organizations involved, which formerly mostly housed older children and teens who crossed the border unaccompanied, have been under new scrutiny.

Most, but not all, of the organizations are nonprofits. In some cases, they’re handling contracts in the hundreds of millions of dollars. Here’s what we know about where that money is going and how the process works.

The contracts and grants can be worth millions of dollars

Before the Trump administration started — and then, in theory, ended — separating children from their parents at the border, about 100 shelters that are part of the unaccompanied alien minors program housed kids who tried to cross into the United States on their own. Even now, most of the children in the program came by themselves. Beyond the 2,300 separated from their parents by Trump, there are thousands of others who made the journey by themselves.

According to Office of Refugee Resettlement (ORR) data, the majority of unaccompanied children migrants are ages 15 and up when they arrive, and most come from Guatemala, El Salvador, and Honduras.

Once children are picked up by border agents, they are generally supposed to be directed to HHS within a few days. HHS is obligated by law to find the “least restrictive” placement for them. Often, that means some sort of temporary shelter until a relative or family friend can be identified to take them.

The shelters can be costly: NBC News reported this week that holding a child in a permanent HHS facility in Brownsville, Texas, costs $256 per night per person.

And those costs add up: Nonprofit Southwest Key Programs is expected to be paid more than $458 million in 2018, according to Bloomberg. According to ORR data, the nonprofit has been awarded about $1.4 billion in grants since 2002. It runs 26 immigrant children’s shelters in Texas, Arizona, and California, including Casa Padre, a former Walmart Supercenter in Brownsville, Texas, that has been in the news frequently in recent weeks. Juan Sanchez, Southwest Key’s chief executive and president, made more than $1.5 million in 2016.

Southwest Key isn’t the only organization making money off of housing migrant kids. According to government data, BCFS, a global network of nonprofit groups, has been awarded $800 million in unaccompanied alien children grants since 2009.

Another nonprofit, International Educational Services, has been awarded grants worth $400 million since 2005.

Shenandoah Valley Juvenile Center, a Virginia juvenile detention center where some migrant children are held, has been awarded nearly $30 million in grants since 2011. It’s currently facing allegations of abuse from children kept there, including that staff beat, handcuffed, and restrained them.

Cayuga Centers, a New York nonprofit where hundreds of separated migrant children have been sent, has been awarded $115 million in grant obligations since 2014 from ORR, according to government data.

There are multiple levels of shelters, ranging from mixed-gender and residential facilities to secure facilities, residential treatment centers, and foster care. Some minors who officials can’t find sponsors for wind up in long-term shelters or foster care situations for months or years. According to ORR data, the average length of stay in shelter care for unaccompanied minors in 2017 was 41 days.

Over the years, the federal government has ramped up its immigrant detention capacity, including shelter for child migrants — and increased its spending on it.

“This is the result of many, many years of policymaking,” said Cecilia Muñoz, former director of the Domestic Policy Council under the Obama administration who is now at New America. “We have a huge amount of immigrant enforcement infrastructure, which, frankly, both sides of the aisle beef up every year.”

The types of facilities used, and the funding provided, depends on the number of children coming in

The ORR’s child minors shelter program contains two components: standard shelters, or the ones that run all the time, and influx shelters, which are used for a sudden increase. Influx shelter costs are generally much greater than standard shelters, but they often go to the standard providers, which are already familiar with the requirements necessary.

Standard shelter grants are generally awarded in three-year cycles that are staggered so there aren’t gaps in availability. HHS is currently accepting applications for $500 million worth of grants for unaccompanied migrant children shelters.

When there is an influx of unaccompanied migrant children, grants and contracts go out for influx shelters. That’s what happened in 2014, for example. Southwest Key ran a temporary shelter in Ventura, California, that year, and BCFS ran facilities at Fort Sill, Oklahoma, and at Lackland Air Force base in Texas. Once they were no longer needed, operations were wound down. Influx facilities were also set up in 2015 and 2016.

“We had to rely on influx facilities on several occasions, but it was because there were big, unanticipated increases in the number of arriving kids,” said Mark Greenberg, a senior fellow at the Migration Policy Institute and former official at the Administration for Children and Families, which oversees ORR, under Obama. “That’s very different from the current situation, where there is this urgent need to expand shelter space because of the family separation children that are being taken in.”

Casa Padre, the Southwest Key shelter at the former Walmart, is designed as a sort of influx shelter in that it has the ability to “accordion” — in other words, expand in accordance with need, a former Obama staffer told me. “The idea behind that shelter was to have a shelter that was smaller but that could expand if there was a big increase in need,” the staffer said. “If you have to start from ground zero, that’s the most expensive way to go, and where the most mistakes happen.”

The staffer emphasized that smaller shelters are always preferable to larger ones, which should only be used when necessary.

Shelters absolutely deserve scrutiny. They might also be better than the alternatives.

A number of the organizations being paid to hold migrant children are currently under tough scrutiny.

A lawsuit alleges that in the Shenandoah Valley Juvenile Center in Virginia, migrant children held there “are subjected to unconstitutional conditions that shock the conscience, including violence by staff, abusive and excessive use of seclusion and restraints, and the denial of mental health care,” according to the Associated Press.

On Wednesday, Reveal News reported allegations that children were forcibly injected with drugs at Shiloh Treatment Center in Houston.

The Government Accountability Office released a report in 2016 contending that there was more HHS could do to monitor the care of unaccompanied migrant children. The report found that ORR was “initially unprepared to care for” the influx of immigrant kids in 2014 and that it didn’t always have the necessary documentation on shelters or complete required visits to shelters given grants. ORR subsequently took steps to improve, including upping efforts to serve and monitor children after they leave ORR’s care, adding new case reporting guidelines, and speeding up the process for on-site monitoring.

Scrutiny on the organizations with grants is certainly important, especially since they’re caring for thousands of children. But the situation is complex, Muñoz emphasized: Keeping migrant kids in group facilities is worse than housing them with relatives or friends in the US, but it’s generally a better option than temporary “tent cities” and Customs and Border Patrol facilities.

“If the dynamic that develops is folks make the argument that it’s immoral for Southwest Key or the Southern Baptists to be running shelters because this is an immoral policy, we could end up with not enough facilities or the wrong kinds of facilities for unaccompanied kids,” Muñoz said. “That would be a really terrible outcome here.”

The Trump administration’s “zero tolerance” policy that resulted in the separation of hundreds of children from their parents has complicated the situation even more. Trump signed an executive order ending the practice of separating children and their parents, but a lot of questions remain around how that’s going to work. And still, there are more children who come across the border by themselves.

Some of the organizations that provide sheltering services are speaking out. A detention center in Yolo County, California, where some immigrant children are held complained last year that it was being sent alleged gang members by the government, though they had no proof. In March, the organization threatened to scrap its contract altogether.

Trump’s family separation practices have only heightened the center’s alarm. Its board of supervisors released a statement saying that no separated children had been sent to its facility. It also has no interest in taking any. “The County does not, and has no interest in, operating a de facto federal prison for forcibly separated youth,” the board said.