Fix race bug