Add template class
change append to target
Allow template to be nested