improved race detection