bug in wait