fixing potential contention bug