A federal court rejected Donald Trump’s latest crackdown on legal immigration on Tuesday, blocking a new rule that would deny visas to immigrants who can’t prove they’ll obtain unsubsidized health insurance. In a sweeping decision that applies nationwide, the court found that the administration illegally rewrote immigration law and relied upon an unconstitutional delegation of authority. The ruling seems designed to appeal to the Supreme Court’s conservative justices, seizing upon their disdain for the regulatory state to shield immigration from Trump’s cruelty.

Although the president frequently maligns individuals who enter the United States without authorization, many of his executive actions have targeted legal immigrants. Lately, his administration has focused on turning away individuals who might rely on social services. The most sweeping example is Trump’s “public charge” rule, which seeks to bar visas for immigrants who would likely rely on welfare, food stamps, Medicaid, or housing assistance. Three different federal courts blocked the policy, finding that the president had exceeded his statutory authority. But in October, Trump also announced a narrower rule targeting immigrants who might need subsidized healthcare. Under this policy, visa applicants must prove that they would not require either Medicaid or tax credits under the Affordable Care Act. Immigrants who can’t meet this burden may not receive visas.

Trump’s rule would have an immediate and perverse effect.

First, it would hit about 60 percent of visa applicants, dramatically curtailing legal immigration into the U.S. Second, it would force immigrants who can satisfy the new standard onto junk insurance. The policy approves “Short Term Limited Duration Insurance plans,” which do not comply with the ACA. These plans can discriminate against preexisting conditions, impose dollar-caps on coverage, demand sky-high deductibles, and refuse to cover essential health benefits. They are a dangerous rip-off. Yet the Trump administration has expanded them in an effort to weaken the ACA, and now seeks to force immigrants to purchase them.

As U.S. District Judge Michael H. Simon explained in Tuesday’s ruling, the president’s attempt to discriminate against immigrants who need healthcare assistance is plagued by legal infirmities. The Immigration and Nationality Act does compel consular officers to reject immigrants who are “likely to become a public charge.” But the law lists a number of factors that must together be taken into consideration when the officer makes this determination, including age, health, family status, assets, and financial status. Under the statute, an officer must weigh all these factors when making a decision, not just a single question of health care status. Congress has repeatedly considered and rejected legislation that would alter this test by expressly barring immigrants who need subsidized health insurance.

Yet Trump’s rule, Simon wrote, would sweep away this holistic analysis and replace it with a “single, dispositive factor”: the immigrant’s ability to buy health insurance with no government assistance. The Constitution directs the president to “take Care that the Laws be faithfully executed”; it does not permit the executive branch to “enact, to amend, or to repeal statutes.” By attempting to amend the INA to exclude a new group of immigrants, Simon concluded, Trump violated the constitutional separation of powers.

As Simon noted, Trump’s rule also relies upon a provision of the INA that allows the president to “suspend the entry of all aliens or any class of aliens” if he finds that their admission “would be detrimental to the interests of the United States.” This statute gained notoriety after Trump used it to justify his travel ban for individuals from Muslim-majority countries.

But while the Supreme Court upheld that policy in 2018’s Trump v. Hawaii, it did not determine the constitutionality of the underlying law, because it was not challenged.

No modern president has abused and exploited his powers more than Trump.

Things have changed since then. Most notably, Justice Brett Kavanaugh ascended to the Supreme Court, replacing the sometimes-moderate Justice Anthony Kennedy. Kavanaugh has already joined his four fellow conservatives in supporting a revival of the “nondelegation doctrine”—the theory that Congress cannot delegate legislative powers to the executive branch. This doctrine grew out of reactionary disdain for the “administrative state,” the agencies that implement federal law. In the hands of a conservative court, it can be wielded to weaken laws that regulate the environment, Wall Street, health care, and elections. Congress has instructed agencies to craft regulations for these fields, delegations that SCOTUS may well strike down.

But Simon wisely recognized that there is another area of law where Congress has given up much of its authority: immigration. The legislative branch has given the president vast powers to restrict immigration, which Trump has seized upon in pursuit of his nativist agenda. Sometimes the president still manages to trip up on statutory limits, but he still has extraordinary leeway to manipulate the law as he sees fit.

Simon acknowledged that Congress may allow the executive to curb immigration in the context of “foreign relations or national security,” since the president “has his own inherent powers” over foreign affairs. (That would explain why the delegation may have been considered legal in Hawaii, which involved a claim of national security issues.) But the health care rule is purely “domestic policymaking.” Trump’s proclamation establishing the rule justifies it solely as a cost-saving measure to reduce a “burden on taxpayers.” (Incidentally, immigrants already use a tiny fraction of health care resources.) Congress, Simon wrote, may not permit the president to dramatically alter immigration law in this “wholly domestic context.” Its delegation here is thus unconstitutional, rendering Trump’s rule void.

This reasoning appears crafted to win the votes of the Supreme Court’s conservative majority. It does not rest on progressive notions of due process or equal protection, nor does it accuse the president of bad faith or discrimination. Rather, Simon simply found that Trump’s rule ran afoul of the Constitution’s careful division of power between the branches. That holding should be catnip for right-leaning justices like Kavanaugh who are on the record doubting the legality of broad delegations.

Affirming Simon’s decision, however, would require the Supreme Court to apply principles consistently, even when it disadvantages a Republican president. There is good cause to question whether the conservative justices will apply this standard when it means clipping Trump’s wings. But since SCOTUS is already keen to reinvigorate the nondelegation doctrine, there is no reason why liberals should not challenge Trump’s overreach on nondelegation grounds. No modern president has abused and exploited his powers more than Trump. If the Supreme Court is going to get serious about reining in executive policymaking, it should start with the man who has rewritten immigration law without a whiff of congressional consent.