added minimum distance parameter