refactor hamming