Small distance function fix