add non-blocking flag to wait