improved centering algo