Change ref to to_mask