The U.S. trade deficit for December shrank dramatically, indicating that the nation’s economy actually strengthened at the end of last year -- contrary to what initial data indicated.

The trade deficit, which measures how much more Americans buy from foreigners compared to how much they sell foreigners, contracted to its narrowest in nearly three years, the Commerce Department said Friday.

Analysts polled by Thomson Reuters expected the deficit to shrink to $46 billion but it actually shrank 21 percent to $38.54 billion from a revised $48.61 in the previous month.

Much of the decrease stemmed from growing U.S. petroleum product exports and declining crude oil imports. Further, the price of those crude oil imports fell, which helped to narrow the trade deficit.

The surprisingly small trade deficit indicates that the initial U.S. government report that the economy contracted slightly in the fourth quarter will be revised to show growth instead.

“The Bureau of Economic Analysis assumed in its initial (fourth-quarter) GDP calculations that the deficit widened from a cumulative $516.8 billion annualized in the third quarter to $557.1 billion in the fourth, but the deficit ended up being broadly unchanged at $517.2 billion,” Paul Ashworth, chief U.S. economist with London-based Capital Economics, said.

“As a result, it looks like net trade was neutral for fourth-quarter GDP growth, whereas the first estimate assumed it subtracted 0.3 percent. Given that GDP only fell by minus 0.1 percent annualized, that would be enough to turn the loss into a gain.”

Earlier the Commerce Department had said that GDP in the fourth quarter fell at a 0.1 percent annual rate after growing at a 3.1 percent rate in the third quarter, the worst performance since the second quarter of 2009, when the recession ended.