generalized some Common functions to operate on templated data structures