Remove the dist function; it is more efficient to compare squared distances