The AR-15–style rifle that authorities say Nikolas Cruz used in his shooting rampage at a Florida high school on Wednesday was easier for the 19-year-old to legally purchase than a handgun, thanks to an absurd discrepancy in America’s gun laws.

While federal law requires gun buyers to be 21 to purchase a handgun, in many states anyone 18 or older can buy rifles. This includes the AR-15, a semi-automatic version of the military’s M16 that was also used in recent mass shootings in Newtown, Connecticut; Aurora, Colorado; and San Bernardino, California.

Federal gun laws have traditionally treated handguns differently from rifles, shotguns, and other long guns. When the Gun Control Act of 1968 was passed, legislators raised the legal age to purchase handguns to 21. Congress likely focused on handguns because they were, and still are, used in the majority of firearm-related crimes.

Yet, 18-year-olds were still allowed to buy rifles, often used for hunting, under the act. At the time, assault rifles like the AR-15 were not popular or widely available to the American public. “Handguns were far, far more common and assault rifles had not reached the market saturation that they have today,” Avery Gardiner, co-president of the Brady Campaign to Prevent Gun Violence, told Slate.

That wasn’t the case for long. “With the rise of assault weapons in the 80s and 90s, the [1968] law was made obsolete,” says Josh Horwitz, executive director of the Coalition to Stop Gun Violence. As assault weapons became more popular over the next few decades among both manufacturers and gun owners, the minimum age requirement of 18 for purchasing long guns still applied to these more powerful rifles.

Subsequent gun laws struggled to keep up with this trend and largely failed to address the gap. Finally, in 1994, Congress passed a federal assault weapons ban that was set to last for 10 years. The law effectively made it illegal to manufacture a wide variety of assault weapons for civilians. Though one could still own and resell existing guns, people weren’t supposed to be able to buy most new AR-15s—it didn’t matter if you were 18, 21, or 45.

A decade later, however, the Republican-controlled Congress let the ban expire. Thus, the Gun Control Act of 1968 is still a major pillar in our current federal firearms laws, especially when it comes to age restrictions. Even though AR-15–style rifles are becoming more and more sought-after—the NRA claimed in 2013 that “Americans own about five million AR-15s”—we’ve in many ways reverted back to laws that were crafted when these weapons were barely available. As Gardiner said, “It’s shocking that a 19-year-old can’t buy a beer, and can’t buy a handgun, but can buy an AR-15 under federal law.”