Three years ago, the Islamic State controlled more than 40 percent of Iraq and a similar-sized chunk of Syria. Abu Bakr al-Baghdadi’s evil caliphate was larger than Great Britain or the combined area of New York, New Jersey and Connecticut. Today, ISIS controls just a small patch of desert and even that may soon disappear.

That doesn’t mean, however, ISIS is history. Baghdadi’s vision drew followers from 100 countries. Those who survived the onslaught of the Iraqi army, Shi’ite militias, Kurdish Peshmerga and Syrian Democratic Forces are laying low, waiting for any opportunity to return.

The question then becomes whether mishandling of governance in areas freed from ISIS will enable its return. Last week’s clashes between Kurdish and Iraqi forces over Kirkuk show just how complicated the post-ISIS terrain will be.

Fortunately, it appears Iraq at least is prepared not only to fill the vacuum, but also to learn from the mistakes that enabled ISIS’s rise in the first place. While Prime Minister Haider al-Abadi’s Baghdad guesthouse is abuzz with tribal sheiks and local politicians from newly liberated areas advising on next steps, he’s also a constitutional stickler. Local councils rather than the central government replace impeached or deceased local officials. And while some politicians are seeking to delay Iraq’s parliamentary elections until displaced Iraqis can return, Abadi has wisely refused.

On Sunday, the Iraqi government announced parliamentary elections will occur May 12, 2018. Keeping to schedule is wise for three reasons. First, seats are allocated by province, so Sunnis have nothing to fear from the Shi’ite-led government going forward with elections.

Second, it averts a constitutional crisis. Had Abadi delayed elections, the parliament would disband, allowing Abadi to rule by emergency decree. That he does not seek dictatorship is a positive sign not only for Iraq, but also for broader Arab political culture.

Third, it gives Iraq’s Sunni Arabs what they want: a chance for a new start.

Herein lies the silver lining to the tragedy wrought by the Islamic State. For all the talk of Iraq’s sectarianism, those Sunni Arabs who survived ISIS terror recognize that it was Iraqi Shi’ites who liberated them while their old-guard leadership fled to Jordan or London.

Indeed, the loudest voices in favor of delaying the election are disgraced politicians who realize voters in Mosul, Ramadi and Tikrit plan to end their power and prominence.

The new willingness to work together as Shi’ites and Sunnis under the banner of Iraqi nationalism is matched in the diplomatic arena by the rapprochement between Iraq and Saudi Arabia.

Indeed, there seems to be a disconnect with foreign pundits who worry Iraq is falling under Iran’s sway when everything Abadi does seems to suggest a desire to strengthen his ties to the Arab world.

Still, Iraq faces incredible problems. Rebuilding will be a multi-year task. What happened in Mosul’s Nineveh province is equivalent population-wise to the destruction of Queens. Importantly, Iraq is not simply seeking donors, but investors. In January 2018, Kuwait will host an investors’ conference to solicit those who see in Iraq not only a victim but also a market.

Then there’s the human cost. The world knows the tragedy of Yezidi girls and women traded as sex slaves. Those who survived will need years of trauma therapy. But so too will Sunni Arab children forced to witness public beheadings or subject to brainwashing in ISIS schools. Most Sunni children, however, have simply missed years of schooling.

Add into this mix the fact that ISIS left behind hundreds of babies born to foreign fighters and non-Iraqi ISIS brides. Baghdad says these children are not Iraqi, and has demanded other countries take responsibility for them. European states like France and Germany so far, however, are refusing to repatriate these babies of terrorists.

Syria may be a tougher nut to crack. Bashar al-Assad may be on top, but the civil war is far from over. Syrian Kurds who were most successful against ISIS are loath to abandon the federal region they established. While Washington has long sought to appease both Turks and Kurds, Ankara could soon force a decision.

Let’s hope that if it does, Washington sides with the Kurds rather than a government which, while a NATO member, has been anything but an ally. As for the rest of Syria, Assad’s embrace of Iran and Hezbollah may mean any quiet is the calm before a new storm.

Michael Rubin, a resident scholar at the American Enterprise Institute, recently returned from a research trip to Iraq.