Fixed race condition