fix a race bug