diff --git a/sweebot.py b/sweebot.py
index 58475f9..782f380 100644
--- a/sweebot.py
+++ b/sweebot.py
@@ -556,6 +556,7 @@ 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)})