added waitUntil to wait for async scripts to complete