new download function that simplifies code