After being detained for four years and even being sentenced to death in Iran, Iranian-American game developer Amir Hekmati was freed last week as part of a prisoner exchange between the US and Iran.

As Ars Technica reports, Hekmati was in Iran and was employed by a company that was reportedly making games critical of the country’s government when he was arrested in 2011. Iran said he confessed to charges of espionage, working with the United States Central Intelligence Agency to make “games with the aim of manipulating public opinion in the Middle East. The goal of the company in question was to convince the people of Iran and the people of the entire world that whatever the US does in other countries is a good measure.”

In 2012, Hekmati was sentenced to death in Iran, but that ruling was eventually overturned and he instead got a sentence of 10 years. The US State Department denied the charges, and his family said Hekmati, who was born in the US, was in Iran to visit his grandmother. Both also said the trial that led to his 10-year sentence took place without Hekmati getting access to a lawyer or being allowed to mount a defense. Hekmati works for Kuma Reality Games, a controversial company that creates games based on real-world conflicts and war headlines.

Hekmati is one of four American prisoners released in the exchange last week, which also included Washington Post journalist Jason Rezaian.