added a better formula to find distance