Adding retry logic when filling template