templating dowhile