President Trump’s executive order on Wednesday ending family separation at the border is entirely legal (at least for 20 days) and shows that good policy can make good politics, but he is also right that only Congress can permanently fix this situation.

The media have fixated on sad images of parents and children at the nation’s border to such an extent that they are downplaying or ignoring other major news items, such as Inspector General Michael Horowitz’s recent report, instead playing border clips in a continuous loop while quoting commentators making over-the-top comparisons to horrendous events in Germany 75 years ago.

These commentators ignore the tragic reality that every time a single parent is criminally prosecuted, that parent’s children must be cared for by someone else. More than half of the women behind bars today have children. It is heartbreaking, but it happens every day to American citizens when an adult violates criminal laws.

President Trump explained this week that only Congress can fix this situation, a fact Homeland Security Secretary Kirstjen Nielsen echoed. A federal judge entered a settlement agreement with the federal government in 2016, augmenting an earlier court proceeding from 1987. Under this court settlement, children who are illegal aliens must be released from federal custody within 20 days of detention. If they are accompanied by an adult held in custody, that means either the two will be separated or the government must reinstate catch-and-release and let them all go into the general public. Only three percent of such aliens ever return for their court date once they are released.

That settlement agreement is referred to as the Flores decision from California. It was enacted under the current terms of the Immigration and Nationality Act (INA), which is Congress’s principal law for foreigners determining who can enter this country, under what terms, how we deal with illegal entries into the country, and how foreigners can become U.S. citizens.

But clearly wanting to do something in response to the situation, the president evidently huddled with his lawyers and policy advisers, telling them to give him options. They came back with several ideas under current law that – while not a full or permanent fix – empowers the president to alleviate the situation.

President Trump put those ideas into Executive Order 13841, which begins:

It is the policy of this Administration to rigorously enforce our immigration laws. Under our laws, the only legal way for an alien to enter this country is at a designated port of entry at an appropriate time. When an alien enters or attempts to enter the country anywhere else, that alien has committed at least the crime of improper entry and is subject to a fine or imprisonment under [8 U.S.C. § 1325(a)]. This Administration will initiate proceedings to enforce this and other criminal provisions of the INA until and unless Congress directs otherwise. It is also the policy of this Administration to maintain family unity, including by detaining alien families together where appropriate and consistent with law and available resources. It is unfortunate that Congress’s failure to act and court orders have put the Administration in the position of separating alien families to effectively enforce the law.

Section 3(a) orders that the secretary of Homeland Security “shall, to the extent permitted by law and subject to the availability of [money provided by Congress], maintain custody of alien families during the pendency of any criminal … proceedings involving their members.”

Separately, Section 3(e) of Executive Order 13841 directs Attorney General Jeff Sessions to “promptly file a request with the U.S. District Court for the Central District of California to modify the Settlement Agreement in Flores,” which the Department of Justice did on Thursday.

Taken together, that means the president is ordering the U.S. Department of Homeland Security (DHS) to keep families together for 20 days – which is the maximum extent “permitted by law” under the Flores settlement – while asking the court to modify that settlement during that limited time.

President Trump is also pressing Congress to pass emergency legislation to amend the INA, such as the bill Sen. Ted Cruz (R-TX) introduced, to permanently fix this situation. The president was correct when he said only Congress can enact such a complete and permanent fix, since the Constitution grants Congress plenary power over immigration.

People should ignore the spin from both sides on this issue. The president is engaging in a situation resulting from bad policies from previous administrations and inaction by Congress, is using every legal tool currently at his disposal to address the problem temporarily, and is working with both of the other branches of the federal government – legislative and judicial – to fix the problem permanently.

If the courts do not modify the Flores settlement, the president can criticize the courts and say it shows the need to confirm more of his judicial nominees to improve the courts.

If Congress does not pass the emergency legislation, the president can rail against obstructionist Democrats in Congress and tee up the subject as a major midterm issue in November, saying to the voters, “Send me lawmakers who will work with me to fix this problem!”

If President Trump’s allies rally to his side to advance this strategy and adopt this message, the president may yet be able to fix this situation while upholding the rule of law.

Ken Klukowski is senior legal editor for Breitbart News. Follow him on Twitter @kenklukowski.