refactor and added clustering library file