changed mechanism for waiting