attempt to fix race condition in _waitfor