The 10 American sailors who were captured Tuesday by Iran's Revolutionary Guards are safe and out of Iranian waters.

The sailors had reportedly entered Iranian waters after their boats experienced a mechanical failure while making a trip between Kuwait and Bahrain.

As soon as word got out that the Americans were being held by Iranians, critics in Washington angrily accused President Barack Obama of weak foreign policy.

If our sailors aren’t coming home yet, they need to be now. No more bargaining. Obama’s humiliatingly weak Iran policy is exposed again.

— Jeb Bush (@JebBush) January 12, 2016

But while critics were tweeting, Secretary of State John Kerry was busy working with Iranian Foreign Minister Javad Zarif to get the Americans released. US government officials said the two leaders spoke at least five times over the span of 10 hours on Tuesday. Finally, the sailors were released on Wednesday morning.

Happy to see dialog and respect, not threats and impetuousness, swiftly resolved the #sailors episode. Let’s learn from this latest example.

— Javad Zarif (@JZarif) January 13, 2016

Barbara Slavin, senior fellow at the Atlantic Council in Washington, DC, says this direct communication was key in getting the matter resolved quickly.

"John Kerry and Javad Zarif are on a first name basis. They've been talking to each other for over two years over the nuclear issue and other issues," she says.

She says it was also in the Iranians interest to send the sailors on their way quickly. "The Iranians are anticipating massive sanctions relief in just a couple of days and I think they were determined [...] not to have anything get in the way,” she says.

The Persian Gulf is a sensitive stretch of waters and prone to incidents like the recent one. In 2007, Iran captured 15 British Navy sailors and marines and held them for 13 days. More recently, last December, the Iranian Revolutionary Guards vessels fired several rockets that came close to US warships, including the aircraft carrier USS Harry S. Truman.

"It's a very crowded place," Slavin says. "Oil tankers, navies of many countries interacting." Slavin thinks Iran and the US should work together to minimize tensions in the region. Especially given that Kerry and Zarif will eventually leave office, severing that that working relationship.

"One of the things that would be useful is to have an 'incidents at sea' agreement between Iran and the United States," she says.

With the nuclear deal now in place, Slavin is hopeful Obama will set up a US interests section in Tehran, like what the US has in Cuba, and send some American diplomats there before he leaves office.

As the recent case of the sailors shows, more communication and diplomacy can't hurt.

From PRI's The World ©2015 Public Radio International