Refactor WaitForDone