Hash table and distance function refined