Should this line read `pending.size++` instead since you're writing to the element and don't want the next iteration through the for loop to overwrite it?