if current.compare(existingValue) == 0 && skippedOne, you could assign newValue and break out of the loop.