The United Nations is not only imperfect, it is also misunderstood. Somewhat predictably, U.S. President-elect Donald Trump and his fellow Republicans unleashed a torrent of criticism against the UN Security Council’s adoption of a resolution on December 23 condemning Israeli settlements in the West Bank and East Jerusalem. To express his disapproval, Trump described the institution as “just a club for people to get together, talk, and have a good time” and went on to suggest that “if it is causing problems rather than solving them … it will be a waste of time and money if it doesn't start living up to its potential.” Several U.S. lawmakers have since demanded that the United States restrict its funding for the global body over the Security Council vote and former Governor of Alaska Sarah Palin even went as far as to call on the United States to leave the UN.

The United Nations’ failures, of course, are well known. Less known is what it gets right, and on this score even Trump should find much to love in the institution. Indeed, if his administration hopes to, as he says, work with all “freedom loving partners” to eradicate terrorism, he will need the UN, warts and all.

In the post–9/11 era—and often at the behest of U.S. Presidents George W. Bush and Barack Obama—the UN has played a central role in globalizing the fight against terrorism and strengthening international cooperation and capacities to defeat al Qaeda, the Islamic State (ISIS), and other terrorist groups. Less than three weeks after 9/11, Bush relied on the UN Security Council to require all countries to reboot or upgrade their counterterrorism laws. As a result, dozens of nations put in place new legal measures to crack down on terrorists and their financiers. Obama likewise went to the UN when he sought to tighten sanctions against and cut off financial flows to ISIS and to push the White House agenda to counter violent extremism around the world. Critical U.S. partners, including China, India, and Russia, and Muslim-majority countries ranging from Egypt to Indonesia, now generally insist that all nonmilitary counterterrorism measures (such as the tightening of border controls, investigating and prosecuting terrorists, or countering radicalization at home) be grounded in some way on the UN counterterrorism framework that evolved rapidly after 9/11. This framework is seen as being in compliance with international law and therefore carries broad global legitimacy, in large part because it is derived from the UN Charter itself.

The comprehensive legal and political framework that the United Nations has developed not only facilitates and underpins international counterterrorism cooperation, including against ISIS, but also makes U.S. efforts more broadly legitimate. This framework includes 19 UN treaties requiring states to criminalize different terrorist acts. Recent legislation adopted by Afghanistan, Burkina Faso, Djibouti, Niger, Nigeria, and Tunisia—developed with the help of UN experts—has incorporated into domestic law key requirements emanating from the framework. It also includes Security Council resolutions that impose obligations on all 193 member states to tighten terrorism laws, strengthen border controls to prevent terrorism, and do more to stem the flow of foreign terrorist fighters to conflict zones. In the wake of these legally binding resolutions, more than 60 countries now have laws in place to prosecute and penalize the activities of foreign terrorist fighters and have in fact prosecuted or arrested such fighters, either prior to departure or upon their return home, or their facilitators. The broadest piece of the framework is the UN General Assembly’s Global Counter-Terrorism Strategy, which provides a hard-won basis for collective action against terrorism. This strategy signaled a shift, at least rhetorically, in international counterterrorism efforts, as it included both preventive and responsive measures, focusing not just on tighter security measures, but also on addressing the underlying political, economic, and social conditions that give rise to terrorism in the first place.

The United Nations, particularly the Security Council, has demonstrated its ability to respond to emerging terrorism challenges—often with strong U.S. leadership. Examples include calling on or requiring states to stop the practice of making ransom payments to terrorists, preventing terrorist groups in Iraq and Syria from benefiting from trade in oil and antiquities, improving international cooperation on counterterrorism investigations and prosecutions, and treating human traffickers affiliated with terrorist organizations as terrorists.

Of course, there is little doubt that the implementation of these measures continues to lag and that if more countries actually did what their UN representatives in New York committed to do, terrorist threats would be reduced. But the lion share of the fault, as with last month’s resolution condemning Israeli behavior, lies with the member states themselves and not the UN as an institution.

Furthermore, through the Security Council, the UN has globalized sanctions. What would otherwise be just a U.S. requirement on U.S. persons or institutions to freeze terrorists’ bank accounts, prevent travel, and stop the flow of arms to terrorist groups is now a coordinated, worldwide effort. At the end of 2016 there were 256 individuals and 75 groups linked to al Qaeda or ISIS subject to these sanctions. Some $136 million in assets were frozen during the first few years following 9/11, largely shutting down terrorists’ use of the formal banking system to raise or transfer funds. Bush’s counterterrorism czar once lauded the UN committee responsible for monitoring the implementation of this UN regime as “one of the most potent bodies in the world in combatting terrorist financing,” adding that “[f]aced with a deadly enemy that recognizes no borders, any nation’s unilateral efforts to combat terrorism are bound to fail.”

And, at the end of the day, governments are much more likely to take the steps necessary to starve terrorists of funding if there is a UN requirement to do so as opposed to just prodding from Washington. For one, it removes the perceived “made in America” stamp from the fight against terrorism, which, despite the progress over the past eight years, continues to be a disincentive to cooperation for some states where there is still lingering criticisms of U.S. counterterrorism policies.

Trump would also need the UN for building the capacity of other countries to fight terrorism. Since 2001, the UN has performed an invaluable and expanding role as a facilitator and provider of counterterrorism-related technical assistance, on top of bilateral assistance from the United States and other countries. For example, the UN has helped Afghanistan, Niger, Nigeria, and more than 100 other countries implement or improve existing counterterrorism laws. It has delivered counterterrorism training to police, prosecutors, and judges in every region of the world—more than 14,000 in all—which has played a role in the dismantling of terrorist plots or in the efficient investigation, prosecution, and adjudication of terrorist cases in a number of counties, including Colombia, Morocco, Nigeria, and Tunisia. It has also established numerous global networks of counterterrorism professionals (most recently one for prosecutors under the auspices of the International Association of Prosecutors); strengthened border security in West Africa (such as addressing the challenges of patrolling the long, unmanned borders in the Sahel); provided specialized training for countries such as Mali and Somalia on the rehabilitation and reintegration of violent extremist offenders; and helped European countries enhance their cooperation against foreign terrorist fighters.

Perhaps most significantly, the UN has amassed what amounts to the most comprehensive inventory of national counterterrorism laws, measures, and policies, bar none, and, based on this information and regular exchanges with member states, it has identified the needs and priorities of each country. Rather than being members of a “club” where members sit around having “a good time,” UN counterterrorism experts visit some of the most difficult and dangerous places in the world, often at risk to their lives (some have in fact been killed). They bring back valuable information on what countries on the frontlines of the terrorist threat need to do to safeguard their citizens.

As both post-9/11 presidents, Bush and Obama, have recognized, the United States cannot simply identify and fund its own counterterrorism priorities. The security of the United States is interwoven with that of other countries. Washington must work with its partners to identify and address counterterrorism needs in every corner of the world—and working closely with the United Nations makes this task much easier. An effective UN can leverage limited resources and help raise the capacity of all states. It can shoulder the burden of providing counterterrorism training and other capacity-building assistance, especially in regions and countries where the United States may lack access or leverage, or which are not priorities for Washington, but nevertheless require attention before violent extremism takes root.

Despite the ways in which an effective UN counterterrorism program benefits the United States (perhaps it does so more so than any other country), the Trump administration’s initial instinct might be to focus on the body’s shortcomings and thus, look for alternatives. And the shortcomings are many: they include the inability of its member states to agree on a definition of terrorism; the competition, duplication, and a lack of coordination among various UN entities; and the gap between the rhetoric in New York and the action (or lack thereof) by states at home. However, working constructively with and through the UN is important given the global nature of the terrorist threat. And so when it comes to counterterrorism, despite the expected flurry of angry Tweets about the institution, Trump will most likely be turning to the UN for help and support before too long.