diff --git a/public/js/thread.js b/public/js/thread.js
index 11a43c0..3acefbb 100644
--- a/public/js/thread.js
+++ b/public/js/thread.js
@@ -1,8 +1,8 @@
 import request from "./request.js";
 
-window.edit_t = async function (id) {
+window.edit_thread = async function (id) {
     const title = prompt("Enter new title!");
-    const res = await request(`/api/threads/${id}/edit`, "PATCH", { title });
+    const res = await request(`/api/threads/${id}/`, "PATCH", { title });
     if (res.error) return;
     alert(`Thread updated`);
     document.getElementById("title").innerHTML = title;
@@ -26,7 +26,7 @@ window.undelete_thread = async function (id) {
 window.edit_message = async function (id) {
     const content = prompt("Enter new content!");
     const res = await request(`/api/messages/${id}/`, "PATCH", { content });
-    if (res.error) return;
+    if (res && res.error) return;
 
     alert(`Message updated`);
     document.getElementById("message-" + id).querySelector(".content").innerHTML = content;
@@ -42,7 +42,7 @@ window.undelete_message = async function (id) {
 }
 
 window.delete_message = async function (id) {
-    const response = await request(`/api/messages/${id}/`,"DELETE");
+    const response = await request(`/api/messages/${id}/`, "DELETE");
     if (response.deleted) {
         alert("Message deleted");
         document.getElementById("dots-" + id).innerHTML = `
diff --git a/routes/api/routes/messages.js b/routes/api/routes/messages.js
index 027fcfd..bca3877 100644
--- a/routes/api/routes/messages.js
+++ b/routes/api/routes/messages.js
@@ -6,7 +6,7 @@ const { Router } = require("express")
 const app = Router();
 
 app.param("id", async (req, res, next, id) => {
-    req.message = await ThreadModel.get(id);
+    req.message = await MessageModel.get(id);
 
     if (!req.message) return res.error(404, `We don't have any message with id ${id}.`);
 
@@ -34,7 +34,6 @@ app.patch("/:id/", async (req, res) => {
     message.edited = true;
 
     await message.save();
-
     res.complate(message);
 
 })
@@ -101,7 +100,6 @@ app.delete("/:id/", async (req, res) => {
 
     message.deleted = true;
     await message.save();
-
     res.complate(message);
 
 })
diff --git a/routes/api/routes/threads.js b/routes/api/routes/threads.js
index 71d40e3..827c9f4 100644
--- a/routes/api/routes/threads.js
+++ b/routes/api/routes/threads.js
@@ -72,6 +72,8 @@ app.delete("/:id/", async (req, res) => {
 
     thread.deleted = true;
     await thread.save();
+    console.log(thread)
+
     await MessageModel.updateMany({ threadID: thread.id }, { deleted: true });
     res.complate(thread);
 
diff --git a/views/thread.ejs b/views/thread.ejs
index 4cda078..3f83b58 100644
--- a/views/thread.ejs
+++ b/views/thread.ejs
@@ -26,7 +26,7 @@
    <% if (user && !thread.deleted){ %>
 
     <a onclick="delete_thread('<%= thread.id %>')" class="btn-outline-primary" >DELETE</a>
-    <a onclick="edit_t('<%= thread.id %>')" class="btn-outline-primary" >EDIT</a>
+    <a onclick="edit_thread('<%= thread.id %>')" class="btn-outline-primary" >EDIT</a>
     <% } else if (thread.deleted) { %>
     <h3 style="display:inline;">This thread has been deleted</h3>
     <a onclick="undelete_thread('<%= thread.id %>')" class="btn-primary" >UNDELETE</a>