Donald Trump lambasted the Trans-Pacific Partnership at Tuesday night’s Republican presidential debate, contending that China would use it to “take advantage of everyone” — generating snickers from journalists and a withering refutation from Rand Paul, who said “we might want to point out that China is not part of this deal.”

But Trump never suggested that China was part of the TPP, only that the country would “come in, as they always do, through the back door” of the agreement. And he was right.

The TPP does indeed allow China and other non-members to reap benefits from the deal without having to abide by any of its terms.

Here’s how it works: TPP and other free trade deals allow signatories to exchange goods without tariffs. But we live in a complicated world, with source materials derived from one country often traveling through a supply chain to another and completed in a third before moving to a retail market.

To cope with this, TPP adds a “rule of origin” chapter to determine whether an amalgamated good qualifies for tariff-free status. This is particularly important in Southeast Asian nations like Vietnam or Malaysia, which get a significant amount of production materials from China.

TPP says that all materials that go into a good, outside of a de minimis 10 percent, must derive from TPP countries. However, there are numerous exceptions and exemptions, along with a confusing set of calculations to determine eligibility. Through these cracks in the agreement, as Trump alluded, China can deliver goods to TPP countries without tariffs.

Right now, the U.S. reserves the right to slap large tariffs on China, as it has done on steel (up to 236 percent), solar panels (up to 78 percent) and tires (up to 88 percent). But under TPP, many products, from agriculture to chemicals to plastics to leather seating, can include up to 60 percent of material from a non-TPP country.

Each product has a specific rule of origin that sets the level of non-TPP material that can be incorporated in a good. The chapter designating which products require which percentages only lists numbers instead of product names, which have to be converted using the international Harmonized Schedule of tariffs.

Green tea, 0902.10 on the Harmonized Schedule, can have a “regional value content” — meaning content from TPP countries — of not less than 40 percent. But that doesn’t mean 40 percent of the content; it means 40 percent of the value of the material, which takes into account shipping, processing, and many other variables. While the final calculations must follow basic accounting principles, they will be by definition inexact, so even more than 60 percent of a good, in reality, could come out of a non-TPP member like China.

Weak rules of origin are most clearly seen in auto production, which has its own special “net cost” method of calculating rule of origin. As Teamsters President James Hoffa has pointed out, while under NAFTA 62.5 percent of a car had to be made in a member country, with TPP that number goes down to 45 percent. An additional schedule of other parts would be considered as coming from a TPP country regardless of its origins, lowering the rule of origin to as much as 35 percent. A car could even be labeled “Made in America,” despite having the majority of its parts originating from China. That includes Chinese steel, currently subject to massive tariffs for U.S. import.

Rules of origin for textiles are allegedly more stringent, but they include a “short supply” list, allowing TPP countries to get their materials from non-TPP nations if they are in short supply within the TPP zone. This includes nearly 200 different fabrics, even certain types of cottons, any of which could come from China and get preferential tariff treatment.

There are also loopholes available. Take for instance Article 3.6, “Materials Used in Production.” This says that, if non-originating material undergoes further production in an originating country, then that material would be treated as originating. So you can imagine a disassembled Chinese product, shipped to Vietnam, put on a production line for completion, and delivered tariff-free to the United States.

Importers and exporters make certifications for the rules of origin, and if they can source materials more cheaply from China or elsewhere, they have an incentive to fudge the numbers to maintain their supply chain. No certification is needed for shipments under $1,000, meaning any scheme to ship large quantities in small segments could slip past inspection.

TPP members can inspect goods, but it’s not as simple as looking at a shirt and divining what part of it came from a certain country; enforcement is difficult and expensive. Brunei, Malaysia, Mexico, Peru and Vietnam have five years to institute a certification system for rules of origin, giving time for importers to maintain their existing systems and figure out how to game TPP rules.

So China would not have to raise any standards or comply with any TPP rules, yet still be able to produce millions of auto parts and textiles for TPP countries at a lower cost, without the burden of tariffs. “This will undoubtedly hurt the competitiveness of American manufacturers, particularly the American auto industry,” said Rep. Dan Kildee (D-Michl.), an opponent of TPP.

While Trump’s bluster certainly could be mistaken for ignorance about TPP, in this case he’s right: China can get their goods to the U.S. and other countries through the back door, in a number of ways, and take advantage of TPP without being part of the agreement. Our trade deficit with China, which for the first 9 months of the year stood at $273 billion, would likely not appreciably change after the agreement, despite the additional trading partners.

Watch the exchange between Trump and Paul: