rewrite write ref