modified code to download data