added getPairs helper function