Fixed a racecondition