Improve waitForObject method.