Added hamming distance function