Maybe you’ve heard of the Laffer Curve. People like to make fun of it every time a conservative, post-Reagan comes into power in the U.S.

The theory is simple enough. The lower the tax rate is, the more companies will reinvest in themselves, creating new jobs, which creates more demand and grows the economy. People will also work harder and earn more money if their tax rate is lower. If the economy grows, the government takes in more in tax revenue, even if they take a smaller percentage in taxes. Here’s what it looks like on a graph:

Oddly enough, people say that Reaganomics failed, but if we consider the Laffer Curve as its core, it’s hard to make that case. According to Investopedia, “[d]uring his time in office, tax revenues received by the government increased from $517 billion in 1980 to $909 billion in 1988.”

Not bad.

One of the things that people forget, oftentimes, when discussing the Laffer Curve is that if the tax rate is lower, rich people and businesses, especially big businesses, will spend less time and money hiding their money from the IRS, which means that end the end, the amount of money that gets taxed will increase.

It’s not that we all couldn’t hide our money from the IRS, but most of us wouldn’t end up saving money after we spent money and time hiding it in the first place. And, you know, the IRS exists to try and prevent this sort of thing.

In May of 2017, it was estimated that there were some $2.5 trillion of untaxed corporate profits stashed overseas. Trump promised to try and fix it on the campaign trail, something he followed through on in his monumental tax overhaul, which, Fortune reports, “requires companies to pay taxes on those earnings at two discounted rates — 15.5 percent on income held as cash and cash equivalents and 8 percent for illiquid assets. Those rates apply to an estimated $3.1 trillion in earnings stockpiled overseas since 1986.”

This is huge for a lot of reasons, not only because it disincentivizes companies to hide money overseas, but another part of the law brought the top federal corporate tax rate to 21%, which puts it roughly on par with the tax rate in Europe, making America a more competitive place to own a business.

So, that’s all cool. But how were these companies hiding their money in the first place?

One of the biggest tax avoidance schemes in history was the Double Irish Arrangement, which accounted for at least $1.2 trillion of the money held overseas. Used by corporations such as Google, Apple, and Microsoft, it exploited both U.S. and European Union tax laws and ticked off both parties immensely.

So, here’s how it works:

An American company makes a lot of money overseas. It knows that if it brings it back it will be taxed at a high rate, so it wants to avoid bringing it back to the United States if it can. Ireland has one of the lowest corporate tax rates in Europe, at just 12.5%, so that’s the place to start.

In order to qualify, you need to set up a subsidiary corporation in Ireland. This means that there will be a legally-defined branch of the company in Ireland that is owned by the American company. We’ll call this new company Irish-1.

That doesn’t get the company off the hook, though, because Ireland still taxes.

So, the company sets up a subsidiary of the Irish company in Bermuda, which has no corporate tax rate, for some reason. We’ll call this company Berm-1.

Here’s the catch: in order to run this scheme, the company needs to have intellectual property, which effectively limits it to companies in the pharmaceutical and technology industries.

Okay, so the American Company, develops some new bit of intellectual property (IP). It assesses the value of that IP at $1 dollar and sells it to Berm-1. Berm-1 increases the value of the IP and licenses it to Irish-1. Because it’s based in Bermuda, there’s no tax charged, even though the IP went up in value.

Irish-1 then sells the product based on the IP in Europe. It takes the cash it makes from the sale and uses it to pay a royalty to Berm-1, from which it had licensed the IP. Since all of the money it makes is charged in royalties by Berm-1, it doesn’t profit, which means that Ireland doesn’t take any money in taxes save a withholding tax for money sent out of the country.

Berm-1 then holds onto the money, earning interest and creating a rainy-day fund, or loans it back to other branches original American company.

This is the essence of the Double Irish arrangement, but it can be taken a step further to avoid withholding taxes that would be paid on the royalties from Ireland to Bermuda. This is called a Double Irish arrangement with a Dutch Sandwich, and, unsurprisingly enough, it is put in place by setting up two more companies.

The first new company is set up in the Netherlands, as it does not charge withholding taxes on transfers from Ireland. Instead of sending the royalties directly from Ireland to Bermuda, they first pass through the company in the Netherlands, before routing to a new company in Ireland.

This new Irish company is registered in Ireland, but it’s a subsidiary of Berm-1, and thus in the eyes of the Irish government, a Bermudian company, which will not be charged Irish taxes. Thus, transferring the money to Bermuda is free.

Consequently, the company pays no taxes in the U.S., either, because Irish-1 and the company in the Netherlands didn’t have any profits. The second Irish company, while having profits, is a subsidiary of the first, under some weird tax rules makes it the same company in the eyes of the tax authorities. Because Irish-1 is an Irish corporation, it doesn’t pay U.S. taxes.

Well, until now. As I said at the beginning of the article, the new tax plan levies tax on overseas cash held by subsidiaries of U.S. companies. It was a good run while it lasted.

And, maybe after seeing all the work required to create this arrangement, you see why it’s mostly companies that take the time and spend the money to abuse the tax law. It seems like a monumental pain in the butt to both figure out and execute.