final version for inversions counting