diff --git a/check_eol-versiondetect/detect-postgres b/check_eol-versiondetect/detect-postgres
index 3a4e1078e5a8270f518d60db7925c3606f5aa8c7..dcb14caed00d016f6c13bad81a76423dcc8053db 100755
--- a/check_eol-versiondetect/detect-postgres
+++ b/check_eol-versiondetect/detect-postgres
@@ -5,31 +5,31 @@
 # detect version of PostgreSQL
 #
 # ----------------------------------------------------------------------------
-# 2020-02-25  v1.0  <axel.hahn@iml.unibe.ch>  initial version
-# 2021-03-26  v1.1  <axel.hahn@iml.unibe.ch>  add locations if postgres is not in PATH
+# 2020-02-25  v1.0  <axel.hahn@iml.unibe.ch>      initial version
+# 2021-03-26  v1.1  <axel.hahn@iml.unibe.ch>      add locations if postgres is not in PATH
 # 2021-08-23  v1.1  <martin.gasser@iml.unibe.ch>  added location for v11
 # 2022-04-07  v1.2  <martin.gasser@iml.unibe.ch>  added location for v13
-
+# 2024-06-11  v1.3  <axel.hahn@iml.unibe.ch>      handle placeholders in otherplaces for latest version
 # ----------------------------------------------------------------------------
 
-#
-# WORKAROUND: add additional locations in $PATH
-#
-#otherlocations="/usr/pgsql-10/bin/ /some/other/postgres/location/bin/"
-
-otherlocations="/usr/pgsql-10/bin/ /usr/lib/postgresql/11/bin /usr/lib/postgresql/13/bin"
+# other locations. When using placeholders (like *) then it looks to the
+# highest number
+otherlocations="
+  /usr/pgsql-10/bin
+  /usr/lib/postgresql/*/bin
+"
 
 POSTGRES=$( which postgres 2>/dev/null )
 test -z "$POSTGRES" &&
   for mypath in ${otherlocations}
-  do
-    test -x "$mypath/postgres" && POSTGRES="$mypath/postgres"
+    do
+      if latest=$(ls -1dtr "${mypath}" 2>/dev/null | sort -n | tail -1 ); then
+        test -x "$latest/postgres" && POSTGRES="$latest/postgres"
+      fi
   done
 
-
-#
 # ----- example output
 #   postgres --version
-#   postgres (PostgreSQL) 9.2.24
+#   postgres (PostgreSQL) 15.6 (Debian 15.6-0+deb12u1)
 
 $POSTGRES --version | cut -f 3 -d " " | cut -f 1,2 -d '.'