Fix race condition error