corrected calculation of the center