Add function

We calculate minimum of distance