Fixed race bug