# how to stop array generating continously

**URL:** <https://talk.observablehq.com/t/how-to-stop-array-generating-continously/8686>\
**Category:** Help\
**Created:** [January 9, 2024, 1:54pm UTC](https://talk.observablehq.com/t/how-to-stop-array-generating-continously/8686 "2024-01-09T13:54:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tvxer](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tvxer/32/8420_2.png) [@tvxer](https://talk.observablehq.com/u/tvxer)\
**Post date:** [January 9, 2024, 1:54pm UTC](https://talk.observablehq.com/t/how-to-stop-array-generating-continously/8686/1 "2024-01-09T13:54:11Z")

</div>

I have 3 cells. When the combined\_nodes function run once, the array keeps generating and appending to the nodes variable. I just only need to generate it once every time I execute the function. Why does this keep happening.

```auto
function combined_nodes(source, target) {
  let unique_nodes = [...new Set([...source, ...target])].map(node => ({ id: node }));
  mutable nodes = [...mutable nodes, ...unique_nodes]
  console.log(unique_nodes)
  console.log(nodes)
  console.log("generated nodes from source and target")
}

mutable nodes = []

combined_nodes(distinctSource, distinctTarget)

```

---

<div class="post-metadata">

**Author:** ![mootari](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mootari/32/581_2.png) [@mootari](https://talk.observablehq.com/u/mootari)\
**Post date:** [January 9, 2024, 2:31pm UTC](https://talk.observablehq.com/t/how-to-stop-array-generating-continously/8686/2 "2024-01-09T14:31:22Z")

</div>

You are referencing both `mutable nodes` and `nodes`. When the cell updates `mutable nodes`, the `nodes` variable gets invalidated and all cells that reference it reexecute, including this cell.
