fixed a memory leakage in clustering