Update: fixing stuff for the distance algo