distance calculation (cont)
modify index