implementing small change as suggested by Denis Ryabov to get a better
distance calculation- Good catch!