Fix on distance formula