This is one of the links and that seems exactly like what you want
I (or anybody else) could provide you with some ready made code, but I much prefer it when people first understand the problem and its solution, rather than just following or even merely using boilerplate code.
That's what happens when you get: "no more addresses"
You just need to reset the search on each new attempt for a new pin.