change totalSize() into private function