https://stackoverflow.com/questions/7744611/pass-variables-by-reference-in-javascript
https://stackoverflow.com/questions/40199592/for-loop-not-modifying-a-global-variable