fix potential concurrency issue