fix problems caused by commit 44f2981fcba040b9de76dc49c77d1b00db74f3a6, some case was missing forwarding of distance_fn