Refactoring of Pair class