diff --git a/sweebot.py b/sweebot.py
index 234eb6a..92d8388 100644
--- a/sweebot.py
+++ b/sweebot.py
@@ -17,6 +17,7 @@ from googleapiclient.discovery import build
 import uuid
 import ssl
 import requests
+global lastquery
 AIurl = environ["AIurl"]
 AIsession = requests.Session()
 AIsession.auth = (environ["AIuser"], environ["AIpass"])
@@ -24,7 +25,6 @@ AImodel = environ["AImodel"] if "AImodel" in environ else "llama2"
 run = 0
 block = 0
 parsed = 0
-global lastquery
 lastquery = "None yet."
 # Dashboard thread
 from flask import Flask, send_file, abort as abrt, redirect as redir
@@ -341,6 +341,7 @@ irl3 = threading.Thread(target=irci3, daemon=True)
 irl3.start()
 ticker=0
 while True:
+    global lastquery
     teext = irc.response_irc().split("\r\n")
     for text in teext:
         if text != "":
@@ -557,7 +558,6 @@ while True:
                             randomname = str(uuid.uuid4())
                             responses_ai[randomname] = aimsg
                             mtline = ""
-                            global lastquery
                             lastquery = f"<p>Channel: {channel}</p><p>Request:</p><br><br><textarea class=code width=100% spellcheck=\"false\" autocapitalize=\"off\" autocomplete=\"off\" autocorrect=\"off\" readonly=\"true\">{chatquery}</textarea><hr><p>Response</p><br><br><textarea class=code width=100% spellcheck=\"false\" autocapitalize=\"off\" autocomplete=\"off\" autocorrect=\"off\" readonly=\"true\">{aimsg}</textarea>"
                             broke = False
                             logs[channel].append({"nick": nick, "content": " ".join(command)})