fix a concurrency bug