diff --git a/app.py b/app.py
index 8437997..a03edc1 100644
--- a/app.py
+++ b/app.py
@@ -63,22 +63,20 @@ def load_user(user_id):
     return User.query.get(int(user_id))
 
 def get_real_ip():
-
-    if "CF-Connecting-IP" in request.headers:
-        return request.headers.get("CF-Connecting-IP").strip()
-
-    if "X-Forwarded-For" in request.headers:
-        forwarded_for = request.headers.get("X-Forwarded-For")
-        ip_list = [ip.strip() for ip in forwarded_for.split(",")]
-        if ip_list:
-            return ip_list[0]
-
-    if "X-Real-IP" in request.headers:
-        return request.headers.get("X-Real-IP").strip()
-
+    headers = request.headers
+    cf_ip = headers.get("CF-Connecting-IP")
+    if cf_ip:
+        return cf_ip.split(",")[0].strip()
+    xff = headers.get("X-Forwarded-For")
+    if xff:
+        return xff.split(",")[0].strip()
+    x_real_ip = headers.get("X-Real-IP")
+    if x_real_ip:
+        return x_real_ip.strip()
     return request.remote_addr
 
 
+
 def is_allowed_ip(remote_ip, allowed_hosts_str):
     if os.path.exists("emergency_access.txt"):
         return True