The global economy is “here” and “done,” President Obama said Wednesday — the question now is under what terms it will be shaped.

Obama spoke at a news conference that was dominated by questions about global trade, the effects of Brexit, and Donald Trump. It followed a summit meeting with the leaders of Canada and Mexico in Ottawa.

“Integration of national economies into a global economy, that’s here, that’s done,” Obama said. Speaking on the second day of a stock market rally, which came after sharp drops following Great Britain’s vote to leave the European Union, Obama said it was important not to draw analogies to what happened with Brexit with trade relations between the U.S., Mexico, and Canada. Obama said ordinary people with concerns about global trade “have a legitimate gripe with globalization.”

But he cautioned that withdrawing from trade deals such as NAFTA, as Trump, the presumptive Republican presidential nominee has threatened, “is the wrong medicine for dealing with inequality.”

Addressing protectionist sentiments, Obama acknowledged what he said was “nostalgia” for a time when everyone was working in manufacturing jobs and belonged to the middle class, even though they lacked college degrees. He said that era has been outmoded “far more by automation than by trade,” adding that the U.S. steel industry was producing just as much as it ever was, but now only needs one-tenth of the workers.

On another issue that has been central to the Trump campaign, immigration, Obama said anti-immigration sentiments have been encouraged by demagogues “back to the 1800’s.”

“You shouldn’t think that is representative of how the American people think,” Obama said, adding that illegal immigration from Mexico to the U.S. is at it’s lowest level since the 1970s.

Obama also took a thinly veiled swipe at Trump, saying someone doesn’t suddenly become a populist be cause they say something controversial to win votes. “That’s not a measure of populism,” he said. “That’s nativism or xenophobia, or it’s just cynicism.”

Mexican President Enrique Pena Nieto was asked to explain a comment he made in March, in which he compared Trump’s “strident tone” to Adolf Hitler and Benito Mussolini.

Pena Nieto responded, “Hitler, Mussolini, we all know the result. It was only a call for reflection and for recognition, so that we bear in mind what we have achieved and the great deal still to achieve.”

Obama also said the U.S. has offered “all assistance available” to Turkey, following the terrorist attack Tuesday at Istanbul’s main airport. He said “we’re still learning all the facts, but we know this is part of our broader shared fight against terrorist networks.”