refactored Pair class