diff --git a/src/reflex/scanners.ts b/src/reflex/scanners.ts
index fb1a436..53c8c9b 100644
--- a/src/reflex/scanners.ts
+++ b/src/reflex/scanners.ts
@@ -1,13 +1,13 @@
 import fetch from "node-fetch";
-import fs, { writeFileSync, createReadStream } from "fs";
+import { writeFileSync } from "fs";
 import generateFileName from "../utils/temp/generateFileName.js";
 import Tesseract from "node-tesseract-ocr";
 import type Discord from "discord.js";
 import client from "../utils/client.js";
 import { createHash } from "crypto";
-import * as nsfwjs from "nsfwjs/src";
-import * as clamscan from "clamscan";
-import * as tf from "@tensorflow/tfjs-node";
+import * as nsfwjs from "nsfwjs";
+// import * as clamscan from "clamscan";
+import * as tf from "@tensorflow/tfjs";
 import EmojiEmbed from "../utils/generateEmojiEmbed.js";
 import getEmojiByName from "../utils/getEmojiByName.js";
 import { ActionRowBuilder, ButtonBuilder, ButtonStyle } from "discord.js";
@@ -28,7 +28,7 @@
     const alreadyHaveCheck = await client.database.scanCache.read(hash);
     if (alreadyHaveCheck?.nsfw) return { nsfw: alreadyHaveCheck.nsfw };
 
-    const image = tf.node.decodeImage(new Uint8Array(fileStream), 3) as tf.Tensor3D;
+    const image = tf.tensor3d(new Uint8Array(fileStream));
 
     const predictions = (await nsfw_model.classify(image, 1))[0]!;
     image.dispose();
@@ -37,32 +37,32 @@
 }
 
 export async function testMalware(link: string): Promise<MalwareSchema> {
-    const [p, hash] = await streamAttachment(link);
+    const [_, hash] = await saveAttachment(link);
     const alreadyHaveCheck = await client.database.scanCache.read(hash);
     if (alreadyHaveCheck?.malware) return { safe: alreadyHaveCheck.malware };
     return { safe: true };
-    const data = new URLSearchParams();
-    // const f = createReadStream(p);
-    data.append("file", f.read(fs.statSync(p).size));
-    const result = await fetch("https://unscan.p.rapidapi.com/malware", {
-        method: "POST",
-        headers: {
-            "X-RapidAPI-Key": client.config.rapidApiKey,
-            "X-RapidAPI-Host": "unscan.p.rapidapi.com"
-        },
-        body: data
-    })
-        .then((response) =>
-            response.status === 200 ? (response.json() as Promise<MalwareSchema>) : { safe: true, errored: true }
-        )
-        .catch((err) => {
-            console.error(err);
-            return { safe: true, errored: true };
-        });
-    if (!result.errored) {
-        client.database.scanCache.write(hash, "malware", result.safe);
-    }
-    return { safe: result.safe };
+    // const data = new URLSearchParams();
+    // // const f = createReadStream(p);
+    // data.append("file", f.read(fs.statSync(p).size));
+    // const result = await fetch("https://unscan.p.rapidapi.com/malware", {
+    //     method: "POST",
+    //     headers: {
+    //         "X-RapidAPI-Key": client.config.rapidApiKey,
+    //         "X-RapidAPI-Host": "unscan.p.rapidapi.com"
+    //     },
+    //     body: data
+    // })
+    //     .then((response) =>
+    //         response.status === 200 ? (response.json() as Promise<MalwareSchema>) : { safe: true, errored: true }
+    //     )
+    //     .catch((err) => {
+    //         console.error(err);
+    //         return { safe: true, errored: true };
+    //     });
+    // if (!result.errored) {
+    //     client.database.scanCache.write(hash, "malware", result.safe);
+    // }
+    // return { safe: result.safe };
 }
 
 export async function testLink(link: string): Promise<{ safe: boolean; tags: string[] }> {
@@ -90,10 +90,16 @@
 
 export async function streamAttachment(link: string): Promise<[ArrayBuffer, string]> {
     const image = await (await fetch(link)).arrayBuffer();
+    const enc = new TextDecoder("utf-8");
+    return [image, createHash("sha512").update(enc.decode(image), "base64").digest("base64")];
+}
+
+export async function saveAttachment(link: string): Promise<[string, string]> {
+    const image = await (await fetch(link)).arrayBuffer();
     const fileName = generateFileName(link.split("/").pop()!.split(".").pop()!);
     const enc = new TextDecoder("utf-8");
     writeFileSync(fileName, new DataView(image), "base64");
-    return [image, createHash("sha512").update(enc.decode(image), "base64").digest("base64")];
+    return [fileName, createHash("sha512").update(enc.decode(image), "base64").digest("base64")];
 }
 
 const linkTypes = {
