fixing a race cond