Fixed double-inversion bug