Now counting inversions as well