Update centroid logic to cacluate once and update code to match styleguide