Unset reference after loop