add timeout to wait()