Former White House chief of staff John Kelly criticized President Donald Trump’s immigration policy, including his decision to declare a state of emergency on the southern border.

“I think the whole national emergency thing right now is going to be wrapped up in the courts, if it even really gets through Congress, which right now it doesn’t look like it will,” Kelly said, according to a CNN reporter. Kelly added, “Thank God we have the courts.”

Appearing at Duke University to discuss his previous role as White House chief of staff in the Trump administration, Kelly also criticized Trump’s rhetoric about migrants trying to cross into the United States, according to NBC.

“By the way, they’re overwhelmingly not criminals,” he said. “They’re people coming up here for economic purposes. I don’t blame them for that.”

Kelly called his job as White House chief of staff the “least enjoyable job I’ve ever had” but defended his tenure, saying that Trump “went from a guy who didn’t know how the system works” to one “who understands how it works.”

“By no means is he a stupid man,” Kelly said about Trump, according to the Duke Chronicle. “He’s an accomplished businessman, and he’s got all the education and whatnot, but not everybody is an expert on everything.”

Kelly said that building a wall “from sea to shining sea” on the southern border was a “waste of money” but acknowledged that some physical barriers would help secure the border.

He blamed Attorney General Jeff Sessions for the child separation policy.

“It kind of surprised us,” Kelly said. “It certainly caught DHS flat-footed and HHS, Health and Human Services, flat-footed.”

He also opposed Trump’s decision to deploy the U.S. troops to help secure the border.

“Generally speaking I would always look for another way to do it,” Kelly said, as reported by NBC News.

Overall, Kelly said that he served in the Trump administration out of a sense of duty, noting that he would have done the same thing under a Clinton administration.

“If Hillary Clinton had called me, I would have done it,” he said.