If you really want to use `doneLoading`, just go down to `if (n !== 0) {´ and change it to `if (n !== 0 && doneLoading) {`.