Added centriod calculation