fix possible concurrency problem