Fix for handling different types of pairs