Smarter separation of template