inversion counting ready and tested