Hamming - refactored.