Fixed the download function