Made centering code more accurate