implemented centroid placement subroutine