The United States trade deficit shrank unexpectedly in August to its lowest level in over seven months thanks to exports moving up to a new record.

The gap was narrowed by 0.5% to just over $40.1 billion, which is the smallest it has been since January of this year, from a $40.3 billion revised deficit in July, said the Commerce Department report on Friday.

Economists had forecasted for a $40.8 billion deficit. The increase in exports was aided by capital goods like equipment for telecommunications, and the shortfall in petroleum that was its smallest in 10 years.

Demand from the country’s trading partners was holding up even though global expansion economically is cooling, giving manufacturers in the U.S. a lift.

Imports have been somewhat restrained as the U.S. is getting closer to energy independence than it has in close to three decades, which limits the need to import oil.

A contracting deficit could be a positive for the country’s GDP figures, said a chief economist prior to the release of the report.

Exports were up 0.2% to over $198.5 billion, with demand for capital good made in the U.S. advancing by $1 billion.

Imports were up 0.1% to just over $238.6 billion during August.

The deficit in petroleum contracted to $13.09 billion, the smallest it has been since July of 2004. U.S. imports of fuel dropped to $27.18 billion, the least amount since November of 2010.

After taking out the effects caused by price fluctuations, which generates numbers used in calculating gross domestic product, the deficit in trade was unchanged very little at just over $47.9 billion from July’s $47.8 billion.

The economy in the U.S. expanded at its quickest pace in 3 years during the second quarter, with an increase in the GDP to an annualized rate of 4.6% after a contraction during the first three months of the year.

Growth expanded to a 3% clip during the third quarter according to estimates from economists.