adding min distance