optimized clustering algo
optimized making distance matrix