make eachPair more flexible