fix possible concurrency issues