added option to change the max hamming distance