Wrap retry max times

For a function that may fail depending on the availability of a service, we do not want the script to crash hard upon the first failing attempt. It would be better if we could redo the call to the external service a few times in case a glitch has occurred in the matrix.