use timed_wait instead of wait