rewrite race-protection