add min distance check