wrote a pairs function