fix download logic