A better way to get xpath by keyword

I wonder if anyone can give a better solution than what I am doing. I am using Click on a button which could have different xpath everytime,
e.g xpath=…/some-cobtainer-X/…/div/…
where X is the one I am looking at. It is an integer and I am using a loop with VerifyElementExists to find it out.
The loop is working but I think there might be some smarter way doing it, e.g. sourcesearch or source extract?

What exactly is the issue? Does the button click fail due to a changing XPath locator?