updated code for downloading