Fix distance computation bug!