Use putPairs instead of array iteration