fix download function