Hm, the use of "document" as variable name is not perfect, as this shadows the global var with the name.
Also confuses when reading the code. Could we have some better term here?

We also should have a project-wide policy with what naming pattern to reference the DOM document, and how to reference "our" documents, so in all places there is no ambiguity.