Added the refreshLoop function to the waitForAll method