Hubert = initially looped through template with for loop, by using match and replace. Changed to use Regexp