Fixed inversion bug