diff --git a/src/commands/help.ts b/src/commands/help.ts
index a040358..e34500f 100644
--- a/src/commands/help.ts
+++ b/src/commands/help.ts
@@ -87,8 +87,8 @@
                 `Select a command to get started${(interaction.member?.permissions as PermissionsBitField).has("ManageGuild") ? `, or run ${getCommandMentionByName("nucleus/guide")} for commands to set up your server` : ``}`  // FIXME
             )
         } else {
-            let currentData = getCommandByName(currentPath.filter(value => value !== "" && value !== "none").join('/'));
-            let current = commands.find((command) => command.name === currentPath[0])!;
+            const currentData = getCommandByName(currentPath.filter(value => value !== "" && value !== "none").join('/'));
+            const current = commands.find((command) => command.name === currentPath[0])!;
 
             let optionString = ``
             let options: (ApplicationCommandOption & {
@@ -97,16 +97,16 @@
             })[] = [];
             //options
             if(currentPath[1] !== "" && currentPath[1] !== "none" && currentPath[2] !== "" && currentPath[2] !== "none") {
-                let Op = current.options.find(option => option.name === currentPath[1])! as ApplicationCommandSubGroup
-                let Op2 = Op.options!.find(option => option.name === currentPath[2])!
-                options = Op2.options || []
+                const Op = current.options.find(option => option.name === currentPath[1])! as ApplicationCommandSubGroup
+                const Op2 = Op.options!.find(option => option.name === currentPath[2])!
+                options = Op2.options ?? []
             } else if(currentPath[1] !== "" && currentPath[1] !== "none") {
                 let Op = current.options.find(option => option.name === currentPath[1])!
                 if(Op.type === ApplicationCommandOptionType.SubcommandGroup) {
                     options = []
                 } else {
                     Op = Op as ApplicationCommandSubCommand
-                    options = Op.options || []
+                    options = Op.options ?? []
                 }
             } else {
                 options = current.options.filter(option => option.type !== ApplicationCommandOptionType.SubcommandGroup && option.type !== ApplicationCommandOptionType.Subcommand) || [];
@@ -117,7 +117,7 @@
             const APICommand = client.commands["commands/" + currentPath.filter(value => value !== "" && value !== "none").join("/")]![0]
             let allowedToRun = true;
             if(APICommand?.check) {
-                APICommand?.check(interaction as Interaction, true)
+                allowedToRun = await APICommand.check(interaction as Interaction, true)
             }
             embed.setDescription(
                 `${getEmojiByName(styles[currentPath[0]]!.emoji)} **${capitalize(currentData.name)}**\n> ${currentData.mention}\n\n` +
@@ -136,7 +136,7 @@
                         ...subcommandGroups.map((option) => new StringSelectMenuOptionBuilder().setLabel(capitalize(option.name)).setValue(option.name).setDefault(currentPath[1] === option.name))
                     )
                 if(subcommandGroupRow.components[0]!.options.find((option) => option.data.default && option.data.value !== "none")) {
-                    let subsubcommands = (subcommandGroups.find((option) => option.name === currentPath[1])! as ApplicationCommandSubGroup).options?.filter((option) => option.type === ApplicationCommandOptionType.Subcommand) || [];
+                    const subsubcommands = (subcommandGroups.find((option) => option.name === currentPath[1])! as ApplicationCommandSubGroup).options?.filter((option) => option.type === ApplicationCommandOptionType.Subcommand) ?? [];
                     subcommandRow.components[0]!
                         .addOptions(
                             new StringSelectMenuOptionBuilder().setLabel("Select a subcommand").setValue("none").setDefault(currentPath[2] === "none"),
@@ -152,7 +152,7 @@
             }
         }
 
-        let cmps = [commandRow];
+        const cmps = [commandRow];
         if(subcommandGroupRow.components[0]!.options.length > 0) cmps.push(subcommandGroupRow);
         if(subcommandRow.components[0]!.options.length > 0) cmps.push(subcommandRow);
 
@@ -163,20 +163,23 @@
             i = await m.awaitMessageComponent<ComponentType.StringSelect>({filter: (newInteraction) => interaction.user.id === newInteraction.user.id,time: 300000})
         } catch (e) {
             closed = true;
-            break;
+            continue;
         }
         await i.deferUpdate();
-        let value = i.values[0]!;
+        const value = i.values[0]!;
         switch(i.customId) {
-            case "commandRow":
+            case "commandRow": {
                 currentPath = [value, "", ""];
                 break;
-            case "subcommandGroupRow":
+            }
+            case "subcommandGroupRow": {
                 currentPath = [currentPath[0], value , ""];
                 break;
-            case "subcommandRow":
+            }
+            case "subcommandRow": {
                 currentPath[2] = value;
                 break;
+            }
         }
 
     } while (!closed);
