refactored to internal pair class