Refactored waitForView()