Fixed potential race condition