complete download function