Before the July 4th weekend, a tragedy occurred in San Francisco. Kate Steinle, 32, was walking with her father on a busy pier when she was allegedly shot and killed by Juan Francisco Lopez-Sanchez, an undocumented immigrant from Mexico with a long rap sheet.

The randomness of this crime shocked the nation, and led to a renewed debate over so-called “Sanctuary Cities” like San Francisco. Several of the leading Republican candidates for president, including Donald Trump, Jeb Bush and Rand Paul, have since weighed-in against sanctuary cities.

Not so fast. “Sanctuary Cities” is a misleading label that has caused a great deal of confusion. The term is a misnomer for those cities and towns that prefer that the federal government handle immigration enforcement. It is wrong to attack sanctuary cities because their policies actually help make our cities and towns safer.

What is a sanctuary city? The most accurate definition of a sanctuary city is a city that has decided to leave immigration enforcement to the federal government, so that their own police force can concentrate on fighting crime. That’s hardly a radical idea; it is a principle that the Supreme Court affirmed in Arizona v. U.S. (2012), which found that only the federal government had authority over immigration enforcement.

There are several hundred sanctuary cities across the country, including Los Angeles, New York, San Francisco and Seattle. Although the policies of sanctuary cities vary from place to place, it might surprise people to know that sanctuary cities do not provide a haven for undocumented immigrants. Federal immigration laws are enforced in sanctuary cities just as in non-sanctuary cities. In a sanctuary city, undocumented immigrants can still be rounded up and deported by the government. Local officials in sanctuary cities can still report undocumented immigrants to the government.

One way to understand why sanctuary cities are a smart idea is to look at their history. Starting in the 1990s, when illegal immigration was on the rise, the federal government rolled out several programs whereby local law enforcement would assist them in catching and removing undocumented immigrants. As it turned out, local police didn’t want to do this – and with good reason.

State and local police are not trained in immigration law and procedures. Holding undocumented immigrants in local jails proved to be very expensive for cities, and led to additional liability and legal issues. Local police forces found that they didn’t have enough time to do their main job, protecting their communities from crime, because they were chasing after people for immigration violations, which are civil infractions.

Worst of all, when local police were turned into immigration agents, it had a detrimental effect on community relations. A 2013 study by the University of Illinois-Chicago found that increased (local) police involvement in immigration enforcement eroded trust of law enforcement among both undocumented and legal immigrants.

As a result of this confusion and pushback, cities turned to sanctuary policies, which in effect tells the federal government: You do your job, we’ll do ours.

Sanctuary cities are doing something right. Crime in San Francisco, for example, is lower than in several other non-sanctuary cities. Sanctuary cities make sense because they allow undocumented immigrants to report crime and volunteer as witnesses with local police, which makes everyone safer. Consider that a long list of cities, mayors, crime victims and law enforcement groups have spoken out against a proposal by House Republicans to withhold federal monies from sanctuary cities.

Steinle’s death was a horrific crime and her killer must be brought to justice. But we shouldn’t let an emotional response to this crime blind us to the realities of the case. Steinle’s death occurred because of a bureaucratic error; given his criminal history, Lopez-Sanchez should never have been released by San Francisco police.

So instead of scapegoating sanctuary cities, lawmakers should be taking steps to ensure better communication between federal and local law enforcement. Besides, we don’t need more immigration enforcement (our government spends more on immigration enforcement than all other federal law enforcement agencies combined); we need smarter and better immigration enforcement.

Until our country tackles comprehensive immigration reform, sanctuary cities make our cities safer. It is misguided, uninformed and myopic to attack them as bad policy.