changed distances idea -- recording indices instead-way easier