tested distance between endpoints calculation -- ready to merge