add cluster function

add new function to detect clusters.