Change implimentation of nonblocking_wait