Simple clustering algorithm