Fix for excluding pairs if the records are in the same dataset