improved downloading functionality