ensurePageLoaded method added