dynamically invoking templates