U.S. economic growth accelerated in the second quarter, the Bureau of Economic Analysis reported Wednesday morning. Real gross domestic product grew at a 4 percent annual rate, beating analysts’ expectations and marking a sharp swing back toward economic expansion after the first quarter’s contraction.

The early months of the year were also less damaging for the economy than previously thought. The BEA reported in its recalculation of GDP that the economy shrank at a 2.1 percent clip in the first quarter, rather than the 2.9 percent previously estimated. That poor result defied other signs that commerce continued to expand during the beginning of the year, such as accelerating job growth and rising inflation. The second quarter’s strong mark was driven by rising personal spending and exports, as well as increases in state and local spending. Businesses adding inventories, however, accounted for 1.7 percentage points of the 4 percent increase. Inventories are not predictive of future growth. Final sales, which reflect demand, grew at a significantly lower 2.3 percent.