Last year, Walt Disney World caused a scandal when it let go of more than 200 IT workers and hired an outsourcing firm to replace them with foreign workers on H-1B visas—a program that helps American employers hire foreign workers with specialized skills that they claim they can’t find in the United States (a claim that makes little sense when laying off people already doing those jobs). Southern California Edison, a utility company based in the Los Angeles area, made a similar move a month later, firing more than 400 IT workers. And this summer, the University of California, San Francisco, laid off 80 tech employees after signing a contract with the same outsourcing firm that Disney hired. This is not how the H-1B program was intended to be used.

The idea behind the visa program was to allow American companies to quickly hire foreign workers with needed skills, which would in turn boost the U.S. economy. And at the outset of the program, laws were put in place specifically to protect American workers from being replaced by companies that might try to hire H-1B visa workers, and pay them less.

In the wake of the firings at Disney and Southern California Edison, there was outrage. A handful of Democratic and Republican Senators urged the Department of Labor to investigate potential visa abuse. Employees filed lawsuits and complaints. Ultimately, nothing happened with these investigations because replacing American workers with H-1B workers is perfectly legal in many cases. That’s due to a loophole in the law that exempts certain companies from complying with the requirement not to displace an American worker when they petition for one of the 85,000 H-1B visas available each year.

When the Immigration Act of 1990 created the H-1B program, the law required all employers to promise that they would pay foreign workers the area’s prevailing wage for their position in order to reduce the incentive of hiring them as cheaper replacement labor. It also required them to show that hiring foreign workers would not “adversely affect” the working conditions of current employees in similar jobs. But that didn’t necessarily protect all workers from being replaced with cheaper labor. For instance, companies could get rid of older employees making a lot more money and hire new H1-B workers who didn’t have leverage in negotiating salaries. In 1998—during the tech bubble—lawmakers amended the law to provide more visas at the request of the growing tech industry. At the same time, legislators cracked down on outsourcing companies that were employing large numbers of H-1B workers from Asia, and then contracting them out to American companies looking to save money. Though these consultants are typically called “outsourcing firms,” in a sense their work related to the H-1B visa program is better described as “insourcing,” since what they’re doing is helping companies find workers abroad whom they bring here for new jobs.

Under the amended law, companies that rely heavily on H-1B workers (more than 15 percent of their workforce) would now face additional scrutiny when applying for visas. These companies would have to promise not only that their H-1B workers would not replace American employees at their own company, but that they wouldn’t be used as replacements at firms that the company had contracts with either.

The new requirement would have provided some additional security for American workers, but a seemingly small, yet significant exemption was also written into the law. It allows those same H-1B reliant companies to ignore the requirements about protecting American jobs as long as they pay the foreign workers at least $60,000 a year, or hire a foreign worker with a master’s degree. It’s unclear why this exemption was included, though critics of the H-1B program say tech companies lobbied for it to undermine the new, tougher restrictions that might impact their ability to hire foreign workers. Considering the average IT worker in the United States makes far more than $60,000, that exemption makes it lucrative—and legal—for companies to displace American workers with cheaper H-1B workers. And it effectively undoes the additional protections of the 1998 bill.

To understand why this exemption was included in the H-1B program, I spoke to Bruce Morrison, a former Democratic Congressman from Connecticut who was the principal author of the Immigration Act of 1990 that created the original H-1B program. Morrison says that the now-controversial program was meant to be stricter than the original H1 visa, a broad program which allowed American companies to recruit foreign workers with specialized skills, often for jobs in the healthcare industry. He and his colleagues capped the number of H-1B visas at 65,000 and introduced the prevailing-wage requirement to protect U.S. workers. Since leaving office, the international outsourcing industry has exploded, and lawmakers expanded the program, while also adding the exemption for worker-displacement requirements. “It was a dastardly deed,” says Morrison, who blames tech industry lobbyists for urging lawmakers to add the caveat so they could keep profiting from comparatively cheap labor. (Morrison is now the chairman of the Morrison Public Affairs Group, which lobbies for a professional group of tech workers, the IEEE-USA.) “It licenses companies to displace American workers in a bill that purports to protect American workers.”

Many Silicon Valley companies argue that they rely on the program to recruit the best and brightest workers. And about 40 percent of the 85,000 H-1B visas available each year don’t go to those companies. Instead, they’re snapped up by outsourcing firms like the ones hired by Disney and California Edison. “This shows how powerful the tech lobby is,” says Ron Hira, who researches the impact of visa programs on the American workforce. “[The H-1B program] is very profitable for all these companies, so they will continue to fight for it.”

Hira, who has analyzed H-1B data obtained through the Freedom of Information Act, says despite the fact that not all companies use the visa program as a source of cheap labor—there’s research showing that immigrants in STEM fields don’t get paid a lot less than their American counterparts—a growing number of companies are misusing the H-1B visas in order to hire cheaper workers. His data shows that two of the largest H-1B contracting firms, Infosys and Tata Consultancy Services—which provided contract workers to Southern California Edison—paid an average of about $71,000 and $66,000, respectively, to their H-1B workers in fiscal year 2013. Meanwhile, the average salary for a computer-systems analyst in Rosemead, California, where the utility company is located, was $92,000. Yet the average IT specialist at Southern California Edison was making even more—$110,000—according to a report from a consulting firm it hired to review compensation. After receiving complaints from displaced workers, the Department of Labor investigated both companies and cleared them of wrongdoing. In an email to The Atlantic, Southern California Edison says the company and its contractors abide by all U.S. labor laws, such as “those requiring valid and appropriate work authorizations” for contractors working in the United States. With the loophole in place, as long as outsourcing companies pay workers $60,000, they aren’t necessarily  breaking the law.

While some lawmakers have proposed raising the $60,000 threshold to $100,000 or more, this would still allow companies to replace American workers. Instead, some have suggested eradicating the salary exemption altogether, which would require H-1B employers to show that they are not replacing American workers, regardless of how much money they are paying the foreign workers. Eliminating this exemption would have bipartisan support, with both independent Senator Bernie Sanders and Republican Senator Jeff Sessions having expressed outrage over the misuse of the H-1B program in the past. But bitter negotiations over comprehensive immigration reform have stalled all immigration reform efforts in Congress, even those that both sides seem to agree upon.

The new administration—and a new Congress—might have better luck moving things forward. Sessions is now poised to take over the Justice Department as President-elect Donald Trump’s nominee for U.S. attorney general. In that role, Sessions would likely place more scrutiny on companies that hire H-1B workers through visa-fraud prosecutions. But ultimately, there’s not much that even Sessions can do as long as the law allows companies to continue exploiting a profitable loophole.