fix concurrency problems