clustering lib code