A migrant girl with a U.S. flag sits on the shoulders of a man marching with other migrants to the Chaparral border crossing in Tijuana, Mexico, Sunday, Nov. 25, 2018, as they try to reach the U.S. The mayor of Tijuana has declared a humanitarian crisis in his border city and says that he has asked the United Nations for aid to deal with the approximately 5,000 Central American migrants who have arrived in the city. (AP Photo/Ramon Espinosa)

Immigration is always a hot topic, but the migrant caravan has really brought it to a boil. Many have seen pictures of women and children fleeing to the U.S. or men throwing rocks and other projectiles at the U.S. border patrol.

What should Americans make of this chaos? Why are there now caravans of “asylum seekers” and increasing numbers of women and children crossing the border illegally?

Surprisingly, the total amount of illegal immigration is significantly down from where it was a decade ago. In 2008, the U.S. apprehended just over 1 million individuals trying to cross the U.S. border illegally. In fiscal year 2018, it was just under 400,000 — and fewer illegal aliens are slipping through undetected.

Yet certain types of migration are increasing. Specifically, unaccompanied children and family units are up. Fewer than 20,000 unaccompanied children crossed the border in 2010, but that number topped 68,000 in FY 2014. It has dipped since then, but was around 50,000 in FY 2018.

The number of family units has also surged from just over 11,000 in FY 2012 to over 100,000 in FY 2018.

The number of requests for asylum and subsequent “credible fear” interviews has also spiked. In 2008, just over 5,000 credible-fear referrals were made. In 2016, it was almost 92,000.

Why? Largely because multiple U.S. laws have glaring loopholes that encourage the illegal immigration of children and families and the use of asylum claims as the preferred method to enter the U.S.

When “unaccompanied alien children” (UACs) from countries other than Mexico or Canada cross the border illegally, the well-intentioned Trafficking Victims Protection Reauthorization Act of 2008 demands not that we quickly return them to family in their home country, but that we essentially treat them as victims of human trafficking. This is true even if a parent illegally in the U.S. paid for them to be smuggled .

The result is that they are connected with family in the U.S. or placed in foster care while they await an immigration court hearing that could be years away. Of course many of these children never show up for their hearing. As a result, less than 5 percent of UACs are removed from the U.S.

Similarly, when an illegal immigrant family crosses the border, the U.S. government is not allowed to detain the child. The 1997 Flores Settlement mandates that unaccompanied children can’t be detained for more than 20 days. But in 2016, the 9th Circuit Court decided that this applied to all children, even those accompanied by parents.

When the parents claim asylum, as many now do, it takes more than 20 days to adjudicate their cases. So the U.S. government has a choice: Do they release the child but detain the parents who have broken the law by illegally entering the U.S. and not had their asylum claims adjudicated? Or release the entire family?

The U.S. would prefer to keep families together in custody awaiting the outcome of their cases, but it is simply not allowed to.

But wait, some say – asylum-seeking isn’t illegal. There is a legal way to do it (at a port of entry) and an illegal way (sneak into the U.S. and then, after being arrested, claim asylum). With the right words and a little coaching, many asylum-seekers pass the credible-fear screening, but fewer than 10 percent of Hondurans, Salvadorans, and Guatemalans end up qualifying for asylum.

Society-wide violence, jobs or reuniting with family are not grounds for asylum. Knowing this, many never show up for court. They simply live illegally in the U.S. once released.

To discourage illegal immigration, the U.S. must change these incentives. Congress should make it much harder for those crossing the border illegally to claim asylum.

Lawmakers should first adjust the asylum-claim process. One way is to first require asylum-seekers traveling to the U.S. southern border to have their asylum claims heard at a U.S. consulate in Mexico.

Interviewers should also ask the asylum-seekers why they did not assert asylum in other countries, such as Mexico. If they fail to explain why, immigration officials should consider this a factor in their decisions.

Second, Congress must close the loopholes. That means rejecting the Flores settlement and instead allowing accompanied children to remain with their parents while they await adjudication of their asylum claims or prosecution for having violated immigration law.

Congress should also reform the Trafficking Victims Protection Reauthorization Act to allow unaccompanied children from countries that are noncontiguous with the U.S. to be quickly repatriated to their home countries.

Yes, other enforcement reforms are needed. But the above fixes would go a long way toward securing the border and deterring illegal immigration.

David Inserra is a policy analyst for homeland security at The Heritage Foundation.