fixing potential concurrency issues