President Trump replaced his controversial ban on travelers from seven Muslim-majority countries with a scaled-back version on Monday, narrowing its scope to block only new applicants for visas and removing Iraq from its coverage. The scaled-back ban represents a considerable defeat for the president, whose original executive order was met with protests and a stern rebuke from the federal judiciary.

The new order, which goes into effect one minute after midnight on March 16, prohibits entry into the United States for citizens of six countries—Iran, Libya, Somalia, Sudan, Syria, and Yemen—for 90 days for those who do not already hold a valid visa. New visas will not be issued and expired visas will not be renewed for citizens from the six countries during the 90-day period.

That’s a major shift from the original January 27 order, which suspended virtually all visa travel from those six countries, as well as Iraq. The sweeping travel ban affected hundreds of thousands of immigrants living inside the United States, including permanent residents from the original seven countries with valid green cards. The ban’s sudden implementation led to chaos at major U.S. airports as hundreds of travelers were blocked from entering the country mid-transit.

In a conference call with reporters on Monday, Homeland Security officials stressed the order’s narrow impact. “If you're in the United States on the effective date of this order, which is March 16, it does not apply to you,” a senior Homeland Security department official said. “If you have a valid visa on the effective date of this order, it does not apply to you.” Travelers from the six countries with valid, multi-entry visas “aren’t going to have any issues,” the official emphasized.

Another major change is the removal of Iraq from the list of countries affected by the moratorium. “On the basis of negotiations that have taken place between the Government of Iraq and the U.S. Department of State in the last month, Iraq will increase cooperation with the U.S. Government on the vetting of its citizens applying for a visa to travel to the United States,” the Department of Homeland Security said in a factsheet on Monday. “As a result of this increased information sharing, Iraqi citizens are not affected by the Executive Order.”

That change came amid strong diplomatic pressure from the Iraqi government, which is currently fighting alongside the U.S. military against ISIS in the country’s northern regions. Iraqi translators who worked alongside U.S. soldiers during the war will also be free to enter the United States; their exclusion from the original order frustrated Pentagon officials until the Trump administration carved out an exemption in February.

In addition, the new order includes a series of exemptions that U.S. immigration officials can use to waive the six-nation visa ban on a case-by-case basis. Those provisions allow officials to issue visas to student and work visa-holders outside the country when the order goes into effect, infants and children, people needing urgent medical care, U.S. government employees, members of certain international organizations, and immigrants to Canada.

Like its predecessor, the new order also shuts down the U.S. Refugee Admissions Program for 120 days, effectively halting the admission of new refugees into the United States for four months. But Monday’s order no longer includes the January 27 order’s permanent ban on Syrian refugee admissions, and it also removes the exemption for religious minorities.

The genesis of Trump’s executive order dates back to his December 7, 2015 call for a “total and complete shutdown of Muslims entering the United States until our country's representatives can figure out what is going on.” Over the course of the presidential campaign, the “total and complete shutdown” shifted towards calls for “extreme vetting,” which, as my colleague David Graham noted, sounded a lot like the current vetting system in place for refugees and immigrants.

Most of the changes seemed designed to insulate the order from a defeat in the courts, and U.S. officials framed it as a valid national-security measure. “This is not a Muslim ban in any way, shape, or form,” a senior Department of Homeland Security official said during the Monday conference call. “This is temporary suspension from six countries that are either failed states or state sponsors of terror.”

But the groups waging legal challenges against the original order were unconvinced. “The only way to actually fix the Muslim ban is not to have a Muslim ban,” Omar Jadwat, the director of the ACLU’s Immigrants’ Rights Project, said in a statement. “Instead, President Trump has recommitted himself to religious discrimination, and he can expect continued disapproval from both the courts and the people.”

Monday’s order will still likely face scrutiny by the judiciary. In the weekend following the original order’s chaotic rollout, multiple federal judges issued temporarily restraining orders, or TROs, that blocked the State Department and Department of Homeland Security from enforcing most of its provisions. The most sweeping injunction was issued by federal district court judge James Robart in Seattle in a lawsuit brought by the states of Washington and Minnesota against the Trump administration.

Those states had argued the January 27 executive order violated the First Amendment’s ban on religious discrimination and the Fifth Amendment’s due-process protections. States typically have little ground to challenge immigration policies by the federal government, but Washington and Minnesota argued they had standing to contest the order by citing its impact on some students and faculty in their public-university systems. A three-judge panel in the Ninth Circuit Court of Appeals agreed to uphold Robart’s injunction on those grounds.

Washington Attorney General Robert Ferguson said Monday the state was reviewing the legal implications after the new order’s announcement. But legal experts noted Trump’s rhetoric and past comments could still threaten the revised order in court.

“Some of the challenges to the initial order would be blunted by the changes reflected in the newly issued travel ban, but the most fundamental constitutional infirmities in the original ban, stemming from its grounding in anti-Muslim sentiment rather than in any rational assessment of danger, all remain,” said Laurence Tribe, a Harvard University constitutional law professor. “History cannot be so easily erased, and the Supreme Court’s decisions about the Religion Clauses and the Equal Protection Clause all reflect a strong concern with religiously or ethnically motivated restrictions that denigrate people based on their beliefs or their ancestry.”