Change to use each_cons from Enumerable