New version with templating