fix download code to wait for end of task