diff --git a/gms/src/main/java/it/inaf/ia2/gms/service/GroupNameService.java b/gms/src/main/java/it/inaf/ia2/gms/service/GroupNameService.java
index 4519f2e148111f9b7f936dff6feaac63daf37433..ffb5d2bf74f1e3f45cd107d46acfffbc95a08419 100644
--- a/gms/src/main/java/it/inaf/ia2/gms/service/GroupNameService.java
+++ b/gms/src/main/java/it/inaf/ia2/gms/service/GroupNameService.java
@@ -85,8 +85,13 @@ public class GroupNameService {
     }
 
     public String getShortGroupName(String completeGroupName, Optional<String> groupPrefix) {
-        if (groupPrefix.isPresent()) {
-            return completeGroupName.substring(groupPrefix.get().length() + 1);
+        if (groupPrefix.isPresent() && !groupPrefix.get().isBlank()) {
+            if (groupPrefix.get().endsWith(".")) {
+                // this branch is kept for retro-compatibility with old API, it will be removed in the future
+                return completeGroupName.substring(groupPrefix.get().length());
+            } else {
+                return completeGroupName.substring(groupPrefix.get().length() + 1);
+            }
         }
         return completeGroupName;
     }
diff --git a/gms/src/test/java/it/inaf/ia2/gms/service/GroupNameServiceTest.java b/gms/src/test/java/it/inaf/ia2/gms/service/GroupNameServiceTest.java
index 46bc11fad771548416c5e70ee7b614b2c9d75c69..6cec8b7ce46670894da7164fe552101fe6f58761 100644
--- a/gms/src/test/java/it/inaf/ia2/gms/service/GroupNameServiceTest.java
+++ b/gms/src/test/java/it/inaf/ia2/gms/service/GroupNameServiceTest.java
@@ -99,4 +99,19 @@ public class GroupNameServiceTest {
     public void extractGroupNamesTestNull() {
         assertTrue(groupNameService.extractGroupNames(null).isEmpty());
     }
+
+    @Test
+    public void testGetShortGroupNameOld() {
+        assertEquals("INAF", groupNameService.getShortGroupName("LBT.INAF", Optional.of("LBT.")));
+    }
+
+    @Test
+    public void testGetShortGroupName() {
+        assertEquals("INAF", groupNameService.getShortGroupName("LBT.INAF", Optional.of("LBT")));
+    }
+
+    @Test
+    public void testGetShortGroupNameEmpty() {
+        assertEquals("LBT.INAF", groupNameService.getShortGroupName("LBT.INAF", Optional.of("")));
+    }
 }