Adding code for inversion count