Another try at distance code
Another try at distance code