added hamming distance calculation