try to compute distance with sparse matrix
change the structure of package