fix a race-condition