adding constructor and destructor to template