Hours after a three-judge appeals court panel began weighing the legal merits of a lower court’s temporary stay of Donald Trump’s controversial immigration order, the president publicly assailed the judges, saying, “A bad high school student would understand” the law backs the executive action.

Reading aloud from statutory text during his remarks to a law enforcement conference of the Major Cities Chiefs Association and Major County Sheriffs’ Association in Washington, D.C., Trump defended his authority to bar entry to “any aliens or … any class of aliens into the United States.”

“It's really incredible to me that we have a court case that's going on so long,” the president added. “Now we're in an area that, let's just say, they are interpreting things differently than probably 100 percent of the people in this room.”

Trump said the statute grants the president authority to suspend, restrict or define classes of aliens who seek to enter the country. “You can do whatever you want … for the security of the country,” he said.

“I don’t ever want to call a court biased, so I won’t call it biased, and we haven’t had a decision yet, but courts seem to be so political, and it would be so great for our justice system if they would be able to read this statement and do what’s right, and that has to do with the security of our country,” the president said. “Right now we are at risk because of what happened,” he added, referring to a Seattle-based federal district court judge’s temporary halt to the administration’s new travel ban.

The Justice Department appealed that decision, and the president’s immigration order could be headed to the U.S. Supreme Court.

Trump for the first time defended the absence of public notice before his Jan. 27 order took immediate effect, saying he initially wanted a month’s preparation, then a week’s notice before issuing his temporary bar to travelers and refugees.

His advisers, the president said, warned him that public notification and a phase-in period would invite a sudden surge of dangerous travelers and refugees from the seven affected countries. For that reason, he said, he imposed his order seven days after his inauguration. The temporary ban on travelers and indefinite bar to refugees from Syria created confusion for some travelers en route to the United States, sparked protests from allied governments, and inspired global public demonstrations. Some former national security and counterterrorism officials argue the president’s order plays into the hands of terrorist groups such as ISIS, which will say it bolsters their claim that the United States is at war with Islam.

The new restrictions are designed to permit the government time to set up “extreme vetting” procedures that could identify individuals traveling into the country from Iran, Iraq, Syria, Somalia, Sudan, Libya and Yemen who wish to harm Americans, the president has said. Early in the presidential primary season, Trump called his policy a “Muslim ban,” before backing away from that characterization. As president he has referred to his policy as an immigration ban.

Trump’s evident frustrations with the legal questions posed Tuesday during oral arguments by the appeals court judges, and his praise for what he said was a superior legal opinion written by a Boston judge, underscored his willingness as president to assert that partisan considerations influence some judges more than the Constitution.

“If the U.S. does not win this case as it so obviously should, we can never have the security and safety to which we are entitled. Politics!” Trump tweeted two hours before his Wednesday morning speech.

It is not unusual for presidents to publicly vent about judicial rulings after decisions that are unfavorable to the government’s position. And many presidents have publicly defended the government’s legal arguments before judicial rulings were handed down. But Trump’s references to judges’ personal political motivations – challenging judges on the basis of bias – is widely considered bad form for the leader of the executive branch, and continues a technique Trump favored as a brash New York businessman, and as a candidate.

The president used his Twitter account to argue that any judges who hold his immigrant order in abeyance should be blamed in the event of terrorist attack involving travelers from the seven identified Muslim-majority countries.

Trump initially directed his ire at U.S. District Judge James Robart in Seattle, who issued a temporary restraining order in response to a challenge filed by Washington state, later joined by Minnesota and Hawaii. The president referred to Robart as a “so-called judge,” a slap widely rebuked by members of Congress and commentators on both sides of the aisle.

“The judge opens up our country to potential terrorists and others that do not have our best interests at heart. Bad people are very happy!” Trump tweeted on Feb. 4 in reference to Robart. “Just cannot believe a judge would put our country in such peril. If something happens blame him and court system. People pouring in. Bad!”

Trump said Wednesday that he had listened to live audio of oral arguments presented to the San Francisco-based Court of Appeals for the 9th Circuit by a Justice Department attorney representing Trump’s position, and by the solicitor general for the state of Washington, who argued the president’s travel ban had harmed his state and represented religious discrimination.

“I was a good student. I understand things. I comprehend very well. OK? Better than, I think, almost anybody,” the president told the audience, describing his analysis of what he heard and viewed on television related to the judicial proceedings.

“It was disgraceful because what I just read to you is what we have and it just can't be written any plainer or better,” Trump said, referring to the statutory text.

Since his swearing-in, the president said he learned more about the terror threat facing the United States, reminding the police and sheriffs that he campaigned to be a law and order president.

“We will work with you on the front lines to keep America safe from terrorism,” he said. “Believe me. I've learned a lot in the last two weeks, and terrorism is a far greater threat than the people of our country understand, but we're going to take care of it. We're going to win. We're going to take care of it, folks.”