add another check to make sure template was not susbst'd in earlier iteration