--- a/dirbrowser/cdbrowser.cpp
+++ b/dirbrowser/cdbrowser.cpp
@@ -536,6 +536,15 @@
     qApp->processEvents();
 }
 
+void CDBrowser::updateAlphamap(const string& tt)
+{
+    char ninit = ::toupper(tt[0]);
+    if (ninit != m_curinitial) {
+        m_alphamap[string(1, ninit)] = CTTitleStartMarker + tt;
+        m_curinitial = ninit;
+    }
+}
+
 void CDBrowser::onSliceAvailable(UPnPDirContent *dc)
 {
     //qDebug() << "CDBrowser::onSliceAvailable";
@@ -552,13 +561,7 @@
 
     for (auto& entry: dc->m_containers) {
         //qDebug() << "Container: " << it->dump().c_str();;
-        char ninit = ::toupper(entry.m_title[0]);
-        qDebug() << entry.m_title.c_str();
-        if (ninit != m_curinitial) {
-            qDebug() << "NEW INITIAL " << ninit;
-            m_alphamap[string(1, ninit)] = CTTitleStartMarker + entry.m_title;
-            m_curinitial = ninit;
-        }
+        updateAlphamap(entry.m_title);
         m_entries.push_back(entry);
         html += CTToHtml(m_entries.size()-1, entry);
     }
@@ -684,12 +687,7 @@
         m_curinitial = 0;
         for (unsigned i = 0; i < m_entries.size(); i++) {
             if (m_entries[i].m_type == UPnPDirObject::container) {
-                char ninit = m_entries[i].m_title[0];
-                if (ninit != m_curinitial) {
-                    m_alphamap[string(1, ninit)] = CTTitleStartMarker +
-                        m_entries[i].m_title;
-                    m_curinitial = ninit;
-                }
+                updateAlphamap(m_entries[i].m_title);
                 html += CTToHtml(i, m_entries[i]);
             } else {
                 html += ItemToHtml(i, m_entries[i], maxartlen);