implemented primitive clustering