Fix race-condition