fix a race-bug