WASHINGTON (CNN) -

It was a good idea back in 2008, in the final days of the Bush administration.

With almost no opposition, Congress passed a new law to protect immigrant children from sex traffickers trying to bring them to the United States. It required judges to hold hearings for youngsters from countries other than neighboring Mexico and Canada, preventing them from possibly getting turned away at the border.

More than five years later, though, the William Wilberforce Trafficking Victims Protection Action Act is having unintended consequences. It contributes to the surge of child migrants from Central America overwhelming the U.S. immigration system.

Now some in Congress want to change the law -- a possibility that could bring more unintended consequences.

How did a law aimed at sex traffickers play a role in Central American kids coming here?

A desire to crack down on the global child slave trade led to the law named for a 19th Century British abolitionist. President George W. Bush signed it the month before he left the White House.

It ensured that children who came to the United States got a full immigration hearing instead of being turned away or sent back. The goal of the hearing? To determine if the children had a valid claim for asylum.

Here's the catch: The immigration courts are so backlogged that it can take years for a child's hearing date to come around. As they wait, most stay with relatives or friends already in the country, attend school and generally go about their lives.

It didn't take long for word to spread to families in Central America: Send the kids, and they'll end up in immigration limbo with little threat of deportation -- all the while getting a decent education.

Why does it take so long for a hearing?

One reason is that Congress has failed to provide enough money for timely hearings, noted Michelle Mittelstadt, director of communications and public affairs at the Migration Policy Institute, an independent non-profit.

From 2002-2013, Congress increased spending on immigration enforcement by 300%, compared with a 70% increase for the immigration courts, she said.

Now the average wait for a hearing is well over a year -- and federal agents have too many cases to chase after everyone who skips a court date.

What else is behind the wave of children from Central America?

Rampant gang crime and faltering economies in Guatemala, Honduras and El Salvador have pushed a growing number of people to want to leave, especially those with relatives in the United States, the Migration Policy Institute says.

Sophisticated smuggling rings flourish with promises to take children through Mexico and across the border into the United States -- even if it takes more than one attempt. Their fee: Several thousand dollars at least.

Then in 2012, President Barack Obama's administration stopped deporting some children living illegally in the United States. It was part of a broader effort to overhaul the immigration system that has stalled due to Republican opposition.

The policy change applied only to those who had been in the country at least five years, but the smugglers ignored that nuance in their sales pitch.

How many children are we talking about?

The government says up to 90,000 children will arrive on their own this year, compared with about 39,000 the Border Patrol detained last year.

According to Border Patrol statistics, 98% of them come from Mexico, Guatemala, Honduras and El Salvador. The statistics show the influx from Mexico dropped dramatically in the past two years, while the flow from the other three rose.

What happens when the kids get here?

The goal is to enter the U.S. immigration system, so many approach border patrol agents to get taken into custody when crossing the Rio Grande Valley into Texas from Mexico.

If from Mexico, they can be turned back -- what is called a voluntary repatriation -- after an initial screening at the border. All others get held by the Border Patrol for up to three days, then must be turned over to the Office of Refugee Resettlement, a part of the Department of Health and Human Services.

During the process, some get bused or flown to holding facilities in other states, leading to protests by local residents unhappy that the immigrants are coming to their town.