Improved custom template variables to know how many there are for the replace