Added the pairWithEnds() method.