Two federal judges just invalidated President Donald Trump’s executive order on immigration, and both for the same reasons. In highly similar opinions—each one is forty-three pages long—federal district judges in Hawaii and Maryland used statements Donald Trump made as a candidate for President to conclude that his revised travel ban on people from six majority-Muslim nations represented unconstitutional religious discrimination.

The judges focussed on many of the same words from candidate Trump and his supporters. For example, on December 7, 2015, then-candidate Trump posted a “Statement on Preventing Muslim Immigration” on his campaign Web site, in which he called “for a total and complete shutdown of Muslims entering the United States until our representatives can figure out what is going on.” After he became President, Trump’s surrogate Rudolph Giuliani explained on television how the executive order came to be. He said, “When [Trump] first announced it, he said, ‘Muslim ban.’ He called me up. He said, ‘Put a commission together. Show me the right way to do it legally.’ ” These statements, among others, prompted the judges to declare the executive order unconstitutional. Their reliance on such statements leads to a peculiar and unsettling possibility: that an identical order would be upheld if Barack Obama had issued it, but that this one was invalidated because Trump was the author.

Are these kinds of statements appropriate evidence for judges to rely on in deciding the validity of Presidential orders? Kate Shaw, a professor at Cardozo Law School, has a forthcoming article in Texas Law Review that, though it was written before the travel-ban litigation, illuminates the relevant legal issues. Shaw’s article does not include examples of judges referring to campaign statements (which may never have been done before), but there are several examples of judges referring to Presidential statements as guides to interpreting underlying executive actions. For example, she writes:

In a challenge to the Obama administration’s executive action on immigration, a Texas district court repeatedly invoked presidential statements when reaching the conclusion that the challenged program likely represented a substantive rule change for which notice-and-comment rulemaking was required. Presidential statements played a similar role in a constitutional challenge to the military’s “Don’t Ask Don’t Tell” policy; in that case, the district court relied on a single presidential speech to reach the conclusion that, _contra _the representations made by the Departments of Justice and Defense, DADT did not advance national security interests. A district court in a third example rebuffed a Guantanamo detainee’s attempts to rely on the contents of a presidential speech to establish changed conditions that rendered his continued detention unlawful. And a fourth case rejected a constitutional challenge to a targeted killing, with the district court pointing to presidential speech as evidence of the continuing threat posed by the target of the strike.

Several of these examples resemble the use of Trump’s statements by the judges in the current cases. In essence, the courts were playing gotcha with the President—accusing him of saying one thing in public while his Administration was saying something else in court. In the fourth example, the courts were relying on the President’s statement as an authoritative summary of the nation’s security interests.

Shaw’s comprehensive analysis persuades me that the judges in the current Muslim-ban cases engaged in a pretty dubious practice by using Trump’s campaign utterances against him. Candidates (and, to a lesser extent, Presidents) talk publicly all the time. They say things off the cuff, improvising in the moment and sometimes making foolish statements or outright mistakes. (Trump, of course, is an extreme example.) In contrast, a formal action by the President’s Administration, in the form of an executive order, is by definition a statement of concrete policy, issued in contemplation of a legal challenge. These actions should stand or fall on their own merits. Presidents should be allowed to receive and accept advice to modify their views without penalty from the courts.

This is especially true when it comes to matters of national security. Presidents have access to a great deal more information than candidates do (and much more than federal judges). Judges should give their statements of the nation’s needs a great deal of deference. It is worth nothing that the executive order blocked by the courts was jointly announced by the Attorney General and the Secretaries of State and Homeland Security, who asserted that its issuance was in the national interest (and not intended to discriminate against Muslims). In the absence of some extraordinary circumstances not evident to me here, those views should be persuasive to a trial-court judge.

In rough terms, Shaw believes that judges should regard Presidential statements about executive action in a similar way that they examine legislative intent with regard to laws—relevant, but not binding. She asserts that “courts should rely on presidential speech only where the president has publicly manifested an intent to enter the legal arena. This manifested intent should make clear that any particular speech is the product of deliberation, and that relevant stakeholders have focused significant attention on the issue.” She was writing in the pre-Trump era, but it seems fair to interpret her meaning as, “Don’t rely on Tweets.” But I would go further and reject the use of Presidential statements altogether. The Muslim ban is either constitutional or it’s not—and Donald Trump’s words on the campaign trail don’t settle that question one way or the other.