improved efficiency of check_related to use hamming distance