some editing to the clustering and storing codes