added minDistance feature