fixing a bug with the baseline inversion