Why does a 2001 2.4 GM 4-cylinder automatic with 39k miles have an intermittent miss when coming to a stop and resting at idle?

Dealer replaced #2 spark plug after third visit and this fixed the miss.