remove unused elements in template