WHEN police officers hear on their radios that a 10-13 or an 11-99 is in progress, they drop what they are doing and go. A 10-13 means an officer needs assistance. An 11-99 means an officer is under attack, and all nearby units must respond.

Such an event happened in Baton Rouge, Louisiana on July 17th, when three officers were killed in an ambush. According to the city’s police chief, they were “targeted and assassinated” with military precision. Given the timing, the killer, Gavin Long, a black ex-serviceman, may have been enraged by the killings of unarmed black men by police in Baton Rouge and Minnesota—as was the black man who, on July 7th, shot dead five officers in Dallas.

In the wake of these shootings, several police departments have changed tactics. In Boston and New York City officers have been ordered to work only in pairs. In New Orleans officers must respond in two patrol cars, instead of the usual one. One former cop speculates that, in future, officers responding to a call may park a block away and avoid using the front entrance, to avoid being ambushed.

After riots in 2014 in Ferguson, Missouri, where an unarmed black man had been shot by a white police officer, many departments tried to get closer to their communities. Police walked the streets rather than using patrol cars, getting to know shop-owners and residents nearly as well as the criminals. But trust between the police and citizens, particularly blacks, has badly broken down. Anti-cop rhetoric is pervasive. Camera phones mean more scrutiny. And there are more than 300m guns around.

Navigating through a crowd in a state with open-carry gun laws is a nightmare. Forty-five states now have them. In Dallas, during the protest at which the five officers were killed, as many as 30 people were carrying rifles. Although the number of police murdered in the line of duty is much lower than in the 1970s, when the average was 127 a year, this year has seen a jump. According to the National Law Enforcement Officers Memorial Fund, 32 officers have been shot dead so far this year. Over the same period last year, 18 were.

In response to Black Lives Matter, some serving and retired officers have created Blue Lives Matter, a pro-police movement. According to the New York Post, Blue-Lives-Matter badges sold out at this week’s Republican convention. In May Louisiana became the first state to pass a Blue Lives Matter bill, which treats attacks on the police as hate crimes. Similar bills are afoot in other states, including Wisconsin and Florida.

Some departments are becoming better at dealing with explosive situations. Even smaller outfits, like Florida’s Palm Beach Gardens force, with just 100 officers, are spending money to improve the way police go about their jobs. A 10,000-square-foot tactical training centre, opening in the autumn, will teach officers to use words, not force, to defuse dangerous moments. In a classic example of the method, in November a man brandishing a knife in Camden, New Jersey was arrested without incident. Police followed him at a distance, encouraging him to drop the knife.

Camden was once one of America’s most dangerous cities. Crime there has reached record lows—homicides fell by 52% between 2012 and 2015—largely because of community policing. Handcuffs and firearms are now considered tools of last resort. As Camden’s police chief remarked not long ago, “Nothing builds trust like human contact.”