diff --git a/include/ui.h b/include/ui.h
index 75a3a1f..d36e67e 100644
--- a/include/ui.h
+++ b/include/ui.h
@@ -7,6 +7,8 @@
 #include <stdbool.h>
 
 #define MAX_UI_ELEMENTS 8192
+#define RESERVED_UI_SLOT 0
+#define UI_ELEM_START_INDEX 1
 
 #define BUTTON_WIDTH 100
 #define BUTTON_HEIGHT 40
@@ -28,7 +30,10 @@ enum ui_elem_type {
 
 struct ui_elem {
   u64 id;
-  rect rect;
+  union {
+    rect rec;
+    line ln;
+  };
   ui_elem_type type;
 };
 
diff --git a/src/ui.c b/src/ui.c
index e44c19d..1493273 100644
--- a/src/ui.c
+++ b/src/ui.c
@@ -73,7 +73,7 @@ bool ui_button(const window *wnd, ui_ctx *ctx, rect rec,
   u64 id = get_id(ctx);
   ctx->elements[id] = (ui_elem){
       .id = id,
-      .rect = rec,
+      .rec = rec,
       .type = UI_ELEM_BUTTON,
   };
 
@@ -111,7 +111,7 @@ ui_node_elem ui_node(const window *wnd, ui_ctx *ctx, ui_node_elem node,
   u64 id = get_id(ctx);
   ctx->elements[id] = (ui_elem){
       .id = id,
-      .rect = node.rec,
+      .rec = node.rec,
       .type = UI_ELEM_NODE,
   };
 
@@ -166,7 +166,7 @@ ui_node_elem ui_node(const window *wnd, ui_ctx *ctx, ui_node_elem node,
     node.rec.topleft.y += ctx->rel_y;
 
     for (u64 i = 0; i < node.inputs; ++i) {
-      if (node.noodles[i].connected_node == 0) {
+      if (node.noodles[i].connected_node == RESERVED_UI_SLOT) {
         node.noodles[i].noodle.p0.x += ctx->rel_x;
         node.noodles[i].noodle.p0.y += ctx->rel_y;
       }
@@ -206,7 +206,7 @@ internal ui_noodle_elem ui_noodle(const window *wnd, ui_ctx *ctx,
   u64 id = get_id(ctx);
   ctx->elements[id] = (ui_elem){
       .id = id,
-      .rect = (rect){0},
+      .ln = noodle.noodle,
       .type = UI_ELEM_NOODLE,
   };
 
@@ -290,37 +290,9 @@ internal ui_noodle_elem ui_noodle(const window *wnd, ui_ctx *ctx,
   if (ctx->mouse_up) {
     if (ctx->hovered == ctx->active && ctx->hovered == id) {
       ctx->hovered = ctx->active = -1;
-
-      for (u64 i = 0; i < ctx->count; ++i) {
-        const ui_elem *elem = &(ctx->elements[i]);
-
-        if (elem->type != UI_ELEM_NODE || elem->id == parent_id) {
-          continue;
-        }
-
-        if (!aabb(elem->rect, ctx->mouse_x, ctx->mouse_y)) {
-          continue;
-        }
-
-        point p0 = (point){
-            .x = elem->rect.topleft.x + elem->rect.w / 2,
-            .y = elem->rect.topleft.y + elem->rect.h / 2,
-        };
-
-        line updated_noodle = (line){
-            .p0 = p0,
-            .p1 = noodle.noodle.p1,
-        };
-        return (ui_noodle_elem){
-            .noodle = updated_noodle,
-            .connected_node = i,
-        };
-      }
-
-      noodle.connected_node = 0;
     }
 
-    if (noodle.connected_node > 0) {
+    if (noodle.connected_node > RESERVED_UI_SLOT) {
       return noodle;
     }
 
@@ -341,7 +313,7 @@ internal ui_noodle_elem ui_noodle(const window *wnd, ui_ctx *ctx,
     return noodle;
   }
 
-  const rect *node = &(ctx->elements[parent_id].rect);
+  const rect *node = &(ctx->elements[parent_id].rec);
   if (!aabb(bounding_box, ctx->mouse_x, ctx->mouse_y) ||
       aabb(*node, ctx->mouse_x, ctx->mouse_y)) {
     return noodle;