Refactored out topPairs function