S&P 500, Nasdaq bounce back to extend gains to 4th day