add while() to avoid spurious wakeups