NO ONE seized by pirates can be considered lucky. But many of the seamen taken hostage by Somali pirates have at least been set free fast, once fat ransoms have been paid. At the height of the piracy scourge off the coast of Somalia almost a decade ago, the average ransom to free a crew and vessel was, by one tally, $3.5m.

Some seamen, however, have languished in captivity for months or even years because their companies balked at coughing up—often because their ship was uninsured, or had run aground, or had been disabled by fire, or had sunk. Crew taken from them were sometimes tortured. “Hard as it may sound, these guys, they don’t have any value,” says John Steed, a former UN man in Mogadishu, Somalia’s capital.

Pirates are still loth to cut their losses by freeing such hostages without payment. Of the few Somali pirates who have given up in this way, most were soon killed, Mr Steed notes, since they could not repay the financiers who underwrote the attacks and the hostages’ upkeep. The resulting trap for such failing pirates and their “forgotten” hostages seemed inescapable.

Yet 54 hostages, held on land by various groups of Somali pirates, have been freed in the last several years. This was because of a new approach, say those who negotiated the deals. Rather than try to convince unscrupulous vessel owners to fork up big ransoms, the negotiators, mostly working for nothing, first estimated the pirates’ costs—often $100,000-$200,000 for renting a boat and getting weapons and kit; expenses for fuel and food; and payoffs to stop government officials, warlords and village elders from interfering. If that amount or a bit more could be raised from charities and sympathisers, pirates would often accept the deal, once convinced that it was their only hope of satisfying their creditors.

It is easier to raise money for “expenses reimbursement” than for the actual ransom, not just because the former is much less. “You can argue that you’re not enriching these people,” says David Snelson, the boss of Pbi2, a security firm in Mogadishu that has helped free some of the hostages. Even so, covering pirates’ expenses proved unpalatable to the UN bureaucracy, so Mr Steed quit in 2013 to continue his efforts from Nairobi, the capital of neighbouring Kenya, through an American charity called Oceans Beyond Piracy. He has cajoled Somali villagers into renouncing pay owed by pirates for food, transport and guard services. (Many villagers did not like the attention that hostages attracted.)

Though negotiators have generally adopted the expenses approach, it is not a magic wand. Eight seamen are still held in Somalia, all of them Iranian fishermen seized in 2015. Negotiators must still convince governments that paying the pirates’ expenses will not benefit people with links to terrorist groups. Negotiators must also contend with pirates fearful of being double-crossed by a rival in their group. Such suspicion is sometimes justified, says Leslie Edwards of Compass Risk Management. His London firm has reluctantly negotiated releases whereby a pirate leader gets a secret extra payment that he will not share with his colleagues.

Somalia’s pirates have seized few hostages of late, thanks largely to more use of armed guards on ships. But iJET, a risk-management firm based in Maryland that uses “a facilitation fee” to secure releases, foresees trouble. It reckons that attacks on easier-to-capture fishing boats will pick up as more Somali fishermen turn to piracy as a protest against overfishing by foreign commercial firms. Anger is rising again, as officials in Somalia’s semi-independent Puntland region cash in by selling licences to foreign boats for catches that are depleting the fish stocks that have hitherto sustained Somali fishermen—without their having to resort to piracy.