added waitUntil method