40 miles is a lot longer than 15 to 20 miles. Build yourself up to comfortably riding 30 miles, and drink more water. I hit the wall last week at mile 35 of what turned out to be a 45 mile ride. I thought that since I had done 60 miles once this season, 40 plus miles would be a piece of cake. It wasn't. I made it, but those last 10, and especially last 5 miles weren't fun.