fixed condition variable bug