moved into the `download` function