centroid method sort of works

getting wrong calculations