The Donald Trump presidency, marked by cruelty, corruption, and disdain for the rule of law, has been disastrous for our democracy. If there is one silver lining, it is this: Trump’s abuses have exposed weaknesses in our laws and institutions that were previously hidden and which we can now begin to try to fix. We learned about one such weakness in February, when Trump relied on the National Emergencies Act to commandeer funding Congress had specifically denied for the construction of a border wall. The latest such legal loophole is another emergency power that could enable the president to turn the military into his own immigration police force.

According to a report in the Daily Caller last week, the Trump administration is considering invoking the Insurrection Act to give federal troops the power to detain and remove undocumented immigrants in the United States, acting essentially as Immigration and Customs Enforcement agents. The White House, when asked about the option last week, refused to rule it out.

If Trump follows through on this plan, it would be a staggering abuse of authority, on par with the president’s declaration of a “national emergency” to build the border wall. In both cases, the president seeks to harness an authority clearly intended for the most dire and unusual of circumstances to deal with a long-standing issue that does not come close to posing an urgent or overwhelming threat. In both cases, the president’s goal is not to avert a catastrophe, but to score political points with his base and consolidate his own power.

The Insurrection Act is an exception to the general rule, enshrined in the Posse Comitatus Act, that presidents may not use the military as a domestic police force. Posse comitatus, in the words of one former Defense Department official, reflects “one of the clearest political traditions in Anglo-American history: that using military power to enforce the civilian law is harmful to both civilian and military interests.” Deploying soldiers as police officers not only violates democratic sensibilities; it increases the risk that interactions with civilians could go disastrously wrong, as armed forces are not trained in conducting law enforcement activities. On the flip side, every soldier engaged in law enforcement is being pulled away from military priorities.

The Insurrection Act gives the president a dangerous amount of discretion.

Despite this strong tradition, there are times when the law permits domestic use of the military. The Insurrection Act allows the president to deploy federal troops to suppress domestic uprisings and enforce the law when civilian law enforcement is impeded or overwhelmed. As its name suggests, Congress intended the law to be used only in the most extraordinary situations, and only where absolutely necessary to preserve civil order. For the most part, presidents have honored this intent. The law has not been invoked since 1992, when George H.W. Bush used it to help suppress riots in Los Angeles following the acquittal of police officers for the brutal beating of Rodney King.

It should go without saying that the presence of undocumented immigrants within the United States does not justify invocation of this potent emergency power. There is no uprising taking place, no breakdown of civil order. For better or for worse, immigration officers are fully capable of carrying out deportations—indeed, they are doing so at record-setting rates.

Unfortunately, however, the Insurrection Act, like the National Emergencies Act, gives the president a dangerous amount of discretion. The Insurrection Act allows the deployment of federal troops “whenever the President considers that unlawful obstructions, combinations, or assemblages, or rebellion against the authority of the United States, make it impracticable to enforce the laws of the United States in any State by the ordinary course of judicial proceedings.” The judgment as to whether these vaguely worded conditions exist is left entirely to the president. The National Emergencies Act, for its part, allows the president to declare a national emergency—and therefore to invoke dozens of special statutory powers—without defining the term or specifying any substantive criteria that must be met.

Both laws are also short on checks and balances to deter or correct abuse. In their current form, neither law includes any express provision for judicial review or any time limits on how long the powers they confer may be exercised. And while the National Emergencies Act includes a weak congressional backstop—any member can force a vote on a resolution to terminate a state of emergency, but passing the resolution still effectively requires a veto-proof majority—the Insurrection Act does not even go that far. Senate Majority Leader Mitch McConnell could thus prevent the Senate from considering any legislation to call off the troops.

Congress enacted these sweeping delegations of power on the assumption that presidents could be trusted to act honorably and in the nation’s interest. Whether such an assumption is wise when passing run-of-the-mill legislation is debatable. When granting presidents extraordinary authorities to implement emergency rule or to deploy federal troops domestically—powers that, by their very nature, pose profound risks to a democracy—trust should never replace careful, substantive limits and rigorous procedural checks.

A rare opportunity now exists for Congress to reform these authorities. Republicans, worried about how a future Democratic president might use emergency powers, are lining up behind legislation to reform the National Emergencies Act. Many of them are no doubt driven by a dislike of Democratic policy goals, rather than a true concern about excessive presidential discretion. Nonetheless, the reform they are supporting—a requirement that Congress approve states of emergency within 30 days—is exactly the type of check that is needed to prevent abuse and presidential overreach. Depending on how events unfold, Republicans might be willing to support similar reforms to the Insurrection Act.

Ironically, some Democrats are balking at National Emergencies Act reform, hinting that the law could be a useful tool for future Democratic presidents faced with an obstructionist Republican Congress. This approach is understandable but shortsighted, and ultimately dangerous for our democracy. Trump is aberrant in many respects, but he is not the first president to misuse power, nor will he be the last. To the extent his actions have highlighted specific authorities that are particularly susceptible to abuse, it is incumbent on Congress to reform these laws before Trump, or another president, exploits them further—employing emergency powers to shut down communications facilities, or deploying the military to suppress anti-government protests. With Trump already having laid the groundwork to challenge the legitimacy of any 2020 election defeat, the issue is as urgent as any this country faces.

Trump has shown what can happen when Congress delegates too much discretion to the president. To call this a “teachable moment” is an understatement. For the sake of our democracy, Congress must heed the underlying lesson behind Trump’s abuses of power and amend the legal framework for emergency powers to replace trust and discretion with meaningful checks and balances.