adding Pair class and cleaning up