hamming distance function done