returns an instance of a generic class by generic method