more intelligent method of waiting for the new window to load