you can make it simpler:

`
if copy:
    raw = raw.copy()

# Rereference the eeg channels
raw._data[eeg_idx] -= ref_data

# Return rereferenced data and reference array
return raw, ref_data
`