fixed a bug in the template class