first draft of full-clustering routine