Spent a while trying to debug but couldn’t figure it out sorry.
Focusing on having pure functions that don’t mutate variables outside of their scope can make code less error prone, easier to debug, and more readable as you can test each function individually.