Bug fix for clustering