finish cluster function