Simplify byPair implementation.