some changes to download code