The Gilroy, California, festival shooting on Sunday, in which a shooter killed three people and injured 12 others, exposed a big weakness in California’s strict gun laws: federalism.

On Monday, Gilroy Police Chief Scot Smithee confirmed the 19-year-old shooter used a WASR 10, a derivative of an AK-47, bought in Nevada. The gun is banned in California, as part of the state’s assault weapons ban. But the shooter was able to get the semiautomatic rifle anyway — in a different state — before taking it to California.

It turns out this happens frequently: Facing California’s tough gun laws — among the toughest in the country — people who want to obtain the weapons and carry out deadly shootings can just get them from neighboring states, like Arizona and Nevada, with much weaker laws.

According to the latest federal data from the Bureau of Alcohol, Tobacco, Firearms, and Explosives, nearly 40 percent of guns used in crimes that could be traced to a source come from outside the state. Arizona is the biggest outside source (8 percent of all traced guns used in crimes), while Nevada is a close second (6 percent). (A caveat: These are only the guns that were successfully found, reported, and traced, so the figures are not 100 percent accurate.)

In states with laxer gun laws, like Texas and Alabama, less than 20 percent of guns typically come from outside the state.

This is a phenomenon seen all across the country in places with stricter gun laws. In New York, more than 70 percent of guns used in crimes come from outside the state. In Chicago, nearly 60 percent. In Massachusetts, almost half.

It’s even an international problem. According to the US Government Accountability Office, at least 70 percent of guns seized and traced in Mexico by the ATF were found to have a US origin. Because the US has very lax gun laws, while Mexico has strict laws, drug cartels and other criminal actors often go to America to buy their weapons.

This is not an inherent failure of gun control laws. The research shows that stricter laws do work: A 2016 review of 130 studies in 10 countries, published in Epidemiologic Reviews, found that new legal restrictions on owning and purchasing guns tended to be followed by a drop in gun violence — a strong indicator that restricting access to guns can save lives.

It’s also not a failure on California’s part, or New York’s, or Chicago’s, or Massachusetts’s. These jurisdictions have done what they can to restrict access to deadly weapons.

The problem, instead, lies in federal and other states’ laws. As long as those are weaker, there’s going to be a limit to how well any stricter gun laws can work at the state level — for the simple reason that someone can always freely travel across the border to obtain a gun, whether for personal use or to sell to others. (This is illegal trafficking under federal law, but because other states’ laws are so weak, to the point they might not even require any sort of paper trail to complete a gun purchase, it’s really difficult to enforce the federal law.)

The real solution, then, lies in changes to federal law. Only Congress and the president can set a baseline, such as universal background checks, an assault weapons ban, and requiring a license to buy and own a firearm, that all states will have to follow.

Until that happens, mass shootings like the one in California over the weekend will remain much easier to pull off, no matter what California does.

For more on America’s gun problem, read Vox’s explainer.