started code to compare distance from stable structure