centroid detection added