In his final address to the United Nations while in office, President Barack Obama called for an end to discrimination based on sexual orientation and gender identity.

“In remote corners of the world, citizens are demanding respect for the dignity of all people no matter their gender or race or religion or disability or sexual orientation, and those who deny others dignity are subject to public reproach,” Obama told the U.N. Genera Assembly in New York on Tuesday.

Obama said barriers such as “religious fundamentalism; the politics of ethnicity, or tribe, or sect; aggressive nationalism; a crude populism [opposed to open borders]” were keeping the world from moving forward.

“[A] nation ringed by walls would only imprison itself,” he said.

“So the answer cannot be a simple rejection of global integration. Instead, we must work together to make sure the benefits of such integration are broadly shared, and that the disruptions – economic, political and cultural – that are caused by integration are squarely addressed.”

“Now, there’s no easy answer for resolving all these social forces … But I do not believe progress is possible if our desire to preserve our identities gives way to an impulse to dehumanize or dominate another group. If our religion leads us to persecute those of another faith, if we jail or beat people who are gay, if our traditions lead us to prevent girls from going to school, if we discriminate on the basis of race or tribe or ethnicity, then the fragile bonds of civilization will fray. The world is too small, we are too packed together, for us to be able to resort to those old ways of thinking,” he added.