President Obama said Friday he would make the trade of five Guantanamo Bay detainees for Army Sgt. Bowe Bergdahl again, despite a flood of criticism from lawmakers over the trade.

“This is something that I would do again, and I will continue to do wherever I have an opportunity, if I have a member of our military who’s in captivity,” Obama told NBC News. “We’re gonna try to get ’em out.”

Lawmakers have questioned whether the president should have released the Taliban militants, but Obama said that the war in Afghanistan was ending and that “you don’t do prisoner exchanges with your friends, you do ’em with your enemies.”

“It’s also important for us to recognize that the transition process of ending a war is gonna involve, on occasion, releasing folks who we may not trust but we can’t convict,” Obama said.

The president also defended the administration’s decision not to inform Congress before the exchange, despite a law mandating 30 days’ notice.

“We had to act fast in a delicate situation that required no publicity,” Obama said.