fixed timing error in waitForPageLoad