Donald Trump’s Muslim ban isn’t a Muslim ban anymore. It’s a much more — terrifyingly — workable policy.

In 2015, Trump proposed a "total and complete shutdown of Muslims entering the United States." Since he’s sewed up the Republican nomination, the proposal no longer targets Muslims per se — but anyone immigrating to the US from (as Trump put it in a speech after the shooting in Orlando) "areas of the world where there is a proven history of terrorism against the United States, Europe, or our allies."

The shift represents a concession for Trump politically — though one that allowed his now-running mate Mike Pence, who’d criticized the initial version of the Muslim ban, to get on board with the new one. But don’t be fooled.

The "terror state" ban is a much more robust policy proposal than the "Muslim ban" ever was. If the Muslim ban seemed to some legal scholars to overstep even the very broad authority that the executive branch has to regulate entry into the US, Trump’s current rhetoric explicitly invokes things the courts have granted deference to in the past.

If someone wanted to minimize Muslim immigration into the US — without raising many constitutional red flags — this is how he might do it.

Banning by religion might have been overreach

When Trump first called for a ban on Muslim immigration in December, there was heated debate among legal scholars about whether such a ban would be constitutional. Surprisingly, the question was unsettled.

Some scholars argued that the plenary power — the judicial branch’s traditional deference to the executive and legislative branches when it comes to immigration law — was broad enough to cover a policy of refusing a visa to any immigrant who might be Muslim.

Trump cites a clause of the Immigration and Nationality Act that allows the president to bar any "class of aliens" from the United States — a clause that historically, according to Adam B. Cox of NYU Law School, has been used as an emergency brake in migration crises. But the president’s power is much broader than that clause — the executive branch, under the plenary power, has a tremendous amount of authority to approve or deny applications for visas every day, with little judicial review.

But neither the emergency brake clause nor the broader plenary power, Cox says, gives the president or immigration officials the power to violate the Constitution. "The question," he says, is: "What do we predict the Supreme Court would do if it confronted such a policy" today?

The Supreme Court has "never been forced to confront a situation where the government has stated clearly that it's excluding people on the basis of their religious beliefs or their ideology or their race — at least in the modern era," Cox says. To him and other scholars, it isn’t at all clear that the Supreme Court would defer to the executive branch’s plenary power if the executive branch were explicitly discriminating on the basis of religion.

As a matter of fact, that struck them as the sort of policy that might cause the Court to take another look at the plenary power doctrine itself. "If President Trump were to issue some kind of broad exclusion of all Muslims, for example," says Kevin Johnson, dean of the UC Davis Law School, "I think that's the kind of order or policy that would attract attention of the courts and would create a vehicle for reconsideration and possible overruling of the plenary power doctrine."

Banning by country is much less likely to be a constitutional problem

Just because the courts might find something unconstitutional doesn’t mean a Trump administration wouldn’t try to do it: "Different administrations take different kinds of views about how aggressive they want to be" in pushing up against the constitutional limits of their power, says Cox dryly.

But it’s much easier, and less risky, to simply change the policy to something constitutionally unassailable.

Religion is a constitutionally protected class. But country of current residence is not.

The Immigration and Nationality Act has a legislative fig leaf warning the government not to discriminate against immigrants on the basis of country of origin or country of residence — but in practice, the government does it all the time. "We often have had national country-specific decisions made in our immigration laws," says Johnson.

Refugee quotas and temporary protected status (which gives temporary legal status to all immigrants present in the US from a given country if their home country is suffering from a natural disaster or war) are granted on a per-country basis. US law puts a cap on how many immigrant visas are granted to a given country in a given year — which ends up putting many Mexican, Indian, and Filipino would-be immigrants in decades-long queues while immigrants from other countries get visas immediately.

When a president says it’s about "security, not religion," the courts tend to oblige

"It’s one thing," constitutionally speaking, "to say ‘I'm going to ban migrants — or Muslims, even — from Yemen,’" Johnson says. "It's another thing saying, ‘I’m going to ban a third of the world from immigrating to the United States because they’re Muslim.’"

Where’s the line between discrimination based on country of residence and discrimination based on race or religion? It’s hard to draw. And it’s certainly conceivable that a blanket ban on immigration from dozens of countries would be too big a step for the courts to countenance. But this is where the plenary power comes in handy.

A lot of the reason the executive branch has such broad authority over immigration is that it’s tied to foreign policy — something where both the courts and Congress cede a great deal of power to presidents. So when the government makes country-based distinctions, Johnson says, "Those are the kinds of things the courts are likely to say have foreign policy implications and should be in the hands of the federal government and the executive branch."

In other words, when Trump and other Republicans say the "terror state" immigration ban is about "security, not religion," they’re using the line that the courts have been most deferential to — intentionally or unintentionally.

The government has treated immigrants from Muslim-majority countries differently before

This isn’t a hypothetical. The US government has, in fact, explicitly discriminated against immigrants from certain Muslim-majority countries on the basis of "counterterrorism" — as recently as 10 years ago.

After 9/11, the then-Immigration and Nationality Service created the National Security Entry-Exit Registration System, or NSEERS. Under NSEERS, adult male immigrants from designated countries had to come into immigration offices for fingerprinting, photos, and interviews — and then had to continue checking in.

Of the 25 countries covered by NSEERS, 24 were places where Islam is the dominant religion. (The 25th was North Korea.) To critics, this was de facto discrimination against Muslim male immigrants in the US.

The courts disagreed. Challenges to the NSEERS program didn’t get very far. One 2006 ruling in the First Circuit Court of Appeals, according to an essay by Nitin Goyal (as a student at the CUNY School of Law), "specifically [cited] the national security justifications for the regulation and the special deference given to the executive and legislative branches over issues of immigration."

From a policy perspective, there’s certainly a big difference between requiring some immigrants to check in with officials more often and barring some immigrants entirely. And UC Davis’s Johnson, at least, expresses some hope that the courts would be a little less deferential to the executive branch than they were in the wake of 9/11.

If anything, though, that’s just another indication of how broad the president’s power is over national security: If something is seen as a crisis, the courts are even less inclined than usual to scrutinize the president’s response.

The nightmare scenario: a silent ban on Muslims

At the same time that Donald Trump is claiming he’d allow Muslims from Scotland into the US, of course, he’s giving speeches and interviews saying Muslims who’ve been living in Western countries — second- and third-generation immigrants — are actually the biggest terror threat to the US. And while his generalizations are abhorrent, his basic point isn’t wrong: Recent terrorist attacks in both Europe and America have been carried out by people born in "the West."

A ban on immigration from certain countries would have some success in addressing his supporters’ root fear about large-scale immigration changing America’s "cultural values," but from an anti-terrorism perspective, a "terror state" ban isn’t actually the most effective thing a President Trump could do. (But, again, that’s much more scrutiny than the courts would subject the policy to.)

But here’s the thing: By pulling a #NotAllMuslims on his immigration ban, Trump isn’t actually promising to allow Muslims into the country, or to not subject them to a higher degree of scrutiny.

In many ways, the process by which the US grants people visas to visit or immigrate is a black box. You can sometimes challenge a visa denial — but as long as the government can give you a "facially legitimate and bona fide" reason your visa was denied, you’re out of luck.

One of those "bona fide" reasons is suspicion of terrorism. If the consular officer processing your application (or a Border Patrol officer when you enter the country) has reasonable suspicion that you’re a terrorist, or a member of a "political, social or other group that endorses or espouses terrorist activity," he doesn’t even have to tell you your visa was denied for that reason.

Add all this together, and it’s all too easy to imagine a world in which many second- and third-generation Muslim immigrants in Europe traveling or immigrating to the United States would have their visas denied for mysterious and possibly attenuated terrorist ties.

The courts aren’t built to poke holes in pretexts

"If you could show statistics that 100 percent of Muslims are being denied," Johnson says, "then you might be able to bring some kind of challenge." But even then, you’d have a very hard time showing that religion was the real cause.

"This was the big obstacle" for the people who tried to challenge the Bush-era "special registration" program, Cox says. "Someone would have to prove in court that the Department of Justice deliberately picked those countries because of, not in spite of, the fact that they’re predominantly Muslim. And that, in 2001, was extremely hard to prove."

"Now, with [a possible] President Trump, given his public statements, it might be easier to prove," Cox continued. But I spoke to him in mid-June — before the Trump campaign fully disavowed any religious basis for its "terror states" ban.

It might be perfectly obvious that "terror states" are a pretext for restricting Muslim immigration — just like it might be perfectly obvious that if more Western Europeans with Arabic or Dari names are being denied visas than their compatriots, religious discrimination might be the cause. But as long as the government can provide a "facially legitimate" reason for the restriction, the courts have decided not to pry too hard.

When it comes to discrimination, Cox says, the courts’ line is that "mere correlation doesn’t give you a constitutional claim."

In other words, Donald Trump has done exactly what he should do if he wanted to become president and institute as much of his Muslim ban as possible without a plausible, high-profile court challenge.

He’s narrowed it to a policy that would, in practice, bar many Muslims from immigrating to the United States — by using criteria that the courts have demonstrated they’re cool with. At the same time, he’s expressed a belief that Muslim immigrants and their descendants are dangerous, and a desire to apply "so much scrutiny" to people coming into the country — a possible invitation for consular officers to set a higher bar for people who seem Muslim applying for visas, without saying anything so crude or explicit that it could be used against him.

Trump has never seemed all that interested in the mechanisms of policy, and it’s not clear whether this shift came from him or his advisers — or even whether it’s intentional. But if someone wanted to succeed in limiting Muslim immigration into the US, Trump’s current position, not his old one, is the place they’d start.