Nikolas Cruz was too young to buy a pistol at a gun shop. But no law prevented the teenager from purchasing the assault-style rifle he allegedly used to kill at least 17 people at a high school in Parkland, Florida, on Wednesday.

Authorities said Cruz, 19, passed a background check and bought the rifle from a licensed dealer in February 2017.

“No laws were violated in the procurement of this weapon,” Peter J. Forcelli, the special agent in charge for the Bureau of Alcohol, Tobacco, Firearms and Explosives in Miami, told The New York Times.

Florida isn’t unique. In most states, people can legally buy assault-style weapons before they can drink a beer. Federal law stipulates that gun stores and other licensed dealers may not sell a handgun to anyone under the age of 21, but they can sell long guns — i.e., rifles and shotguns — to anyone who is at least 18, according to Giffords Law Center to Prevent Violence.

Only two states — Hawaii and Illinois — have raised the minimum age to purchase a long gun to 21.

And when it comes to owning a gun, age limits are even looser. There is no federal minimum age requirement for long guns. As The Washington Post pointed out, if a father wants to buy his young son a rifle for his birthday, it is perfectly legal for him to do so in much of the country.

Twenty-three states have set minimum age requirements for the ownership of long guns, ranging from 14 in Minnesota to 21 in Illinois and Hawaii. In the District of Columbia, a person has to be 21 to own a long gun unless they have parental consent, in which case they only have to be 18. In Florida, where Wednesday’s mass shooting took place, the minimum age requirement for owning a long gun is 18.

Handguns are subject to much stricter requirements. A 1995 Bureau of Justice Statistics report found that handguns were involved in more than 85 percent of gun-related crime. Handguns were involved in 57 percent of all homicides (including non-gun-related killings), while rifles were connected to just 3 percent.

But assault-style rifles have been used in many of the high-profile mass shootings over the last six years. In 2012, Adam Lanza used a rifle made by Bushmaster to kill 20 children and six adults at Sandy Hook Elementary School in Connecticut. Omar Mateen was armed with a Sig Sauer rifle when he massacred 49 people at the Pulse nightclub in Florida two years ago. Stephen Paddock reportedly had multiple assault-style rifles when he sprayed bullets into a crowd of Las Vegas concertgoers in October, killing 58 and wounding hundreds.

Last year, the Fourth Circuit Court of Appeals declared assault-style rifles weapons of war. The ruling meant that Americans did not have an unfettered right to buy such rifles under the Second Amendment and that states were free to regulate them. Seven states and the District of Columbia have banned such rifles. Florida is not one of them.