Fixing mistakes with counting comparisons and median of 3 algo