Iraq may be winning against the Islamic State group on the battlefield, but it is struggling to prevent deadly militant attacks in Baghdad that are undermining the government.
A suicide bombing claimed by IS ripped through a crowded shopping area in the Karrada district of Baghdad early on Sunday, killing more than 200 people just a week after Iraq announced it had fully recaptured the city of Fallujah from the militants.
Fallujah was just the latest in a string of IS defeats, but its losses have not stopped the group from carrying out bombings, and may in fact encourage it to step up such attacks.
"The Iraqi government in the best of times could barely control the security situation," said Patrick Skinner, a former CIA case officer who is now with The Soufan Group consultancy. "Now is clearly not the best of times, and more attacks are unfortunately likely," he said.
Prime Minister Haider al-Abadi announced a series of changes to Baghdad security measures following the blast that highlighted various long-running problems in the capital.
Chief among them was the use of fake hand-held "bomb detectors" sold to Iraq by James McCormick, who was sentenced to 10 years in jail in Britain for fraud in connection with the devices in 2013.
NO PHONES AT CHECKPOINTS
Abadi ordered the devices removed from checkpoints, but on Monday in central Baghdad they were still being carried by soldiers and police who said the order to stop using them had not yet come down.
He also directed that security personnel not use mobile phones at checkpoints, but even if that happens, the broader problem of inattentive forces bored by long hours on duty will remain.
Abadi told the interior ministry to speed up the deployment of scanning devices at entrances to the capital, indicating that this measure, which could help identify bombs or the material to make them being brought into Baghdad, had still not been implemented.
And he called for coordination and integration among security forces that is "far from conflicts" - a sign that such coordination is currently lacking.
Even if the new measures are fully carried out, preventing all bombings in the capital would be extremely difficult.
Bombings in Baghdad have sparked anger among Iraqis, who accuse authorities of not doing enough to keep them safe, undermining already low confidence in the government.
"Public anger at the inability of the central government to protect them is sadly one of the common sentiments between all factions and sects," Skinner said. "It is not enough to unify them, but it is enough to further pull the country to the extremes," he said.
A GRIM PREVIEW
This anger is further damaging to Abadi, whose reputation was already hurt by failed efforts to change the cabinet and carry out other reforms.
"The main political point now ... is Abadi's weakness and lack of credibility," said Kirk Sowell, a Jordan-based political risk analyst and the publisher of Inside Iraqi Politics.
Abadi faced an angry crowd when he visited the site of Sunday's bombing, with one video showing men throwing rocks at what was said to have been his convoy, while a man could be heard cursing him in another clip.
He has hailed progress made by security forces against IS, but that ultimately means little to Baghdad residents when they face the possibility of being killed whenever they leave their homes.
And battlefield victories may encourage the militant group to return to its insurgent roots and step up attacks such as the deadly blast in Karrada.
"I see a reversion to the prior status quo of car bombings, (improvised explosive devices), assaults here and there," said Aymenn al-Tamimi, a jihadism expert and research fellow at the Middle East Forum.
"There was a similar trend back in 2009 as IS's predecessor (the Islamic State of Iraq) experienced losses," Tamimi said.
The Karrada bombing therefore offers a grim preview of what IS can do, even in defeat.
"The attack is part of a larger trend of (IS) sliding back down from proto-state to terrorist group," said Skinner. "Karrada sadly fits the trend for the foreseeable future," he said.