fix bug in inversion count