U.S. Navy/Getty

At the very end of his presidency, Barack Obama is working to fix one of the biggest blights on his record.

On Thursday, he lashed out at Congress for failing to close the prison in Guantanamo Bay, Cuba. As a candidate, he pledged to close the prison and transfer its remaining detainees either to other countries or other facilities in America, but failed to do so in his eight years in office. In a letter, Obama wrote that the facility “never should have been opened in the first place” and that “there is simply no justification beyond politics for the Congress’s insistence on keeping the facility open.” Donald Trump, meanwhile, not only pledged to keep it open but to “load it up with some bad dudes.”

The Obama administration is working to reduce the number of detainees being held before Trump takes office. Ten detainees were sent to Oman on Monday and on Thursday Foreign Policy reported that four more detainees were being transferred. Foreign Policy also reported that “lawyers and Obama administration officials are working down to the wire to get remaining detainees out of Guantánamo before Trump throws away the key, potentially for good.”

The Guantanamo facility has been a blight on the United States’s human rights record and on its international reputation since it was opened. Some of the detainees are being held indefinitely and have never been tried outside a special military court. Even if Congress has proved the main obstacle to closing Guantanamo, failing to do so will undoubtedly be a black mark on Obama’s legacy. Obama is well aware of this—the last minute efforts, though certainly too late, reflect as much. “If this were easy, we would have closed Guantánamo years ago,” Obama wrote in his letter to Congress. “But history will cast a harsh judgment on this aspect of our fight against terrorism and those of us who fail to bring it to a responsible end.”