count inversions is working