After two arduous years, American engineer and US Navy veteran Mark Randall Frerichs was finally released by the Taliban after President Joe Biden agreed to a prisoner swap deal.

The Biden administration has been working on releasing Frerichs for months after the Illinois native was captured by the rebels while doing contract work in a high conflict zone. In January, the US called out the Taliban for keeping Frerichs for years. They said that he has been helping locals for years. At the time, the US was unwilling to negotiate any terms.

“Threatening the safety of Americans or any innocent civilians is always unacceptable, and hostage-taking is an act of particular cruelty and cowardice. The Taliban must immediately release Mark before expecting any consideration of its aspirations for legitimacy. This is not negotiable,” said Biden in a press release.

After months of coordination with the Taliban, Frerichs was finally freed and brought home. However, it did not mean the negotiations went as smoothly. A senior administration official told CNN that releasing Haji Bashir Noorzai, a prominent Taliban leader, was crucial to the negotiations.