clustering algo in place