fix file download function