Checking if element exists already in the sets before adding to cand_set
& ref_set