function imageData = downloadAndReadImages(B4URL)

pkg load image
B2URL = strrep(B4URL,"B04.jp2","B02.jp2");
B3URL = strrep(B4URL,"B04.jp2","B03.jp2");
B4URL = strrep(B4URL,"B04.jp2","B04.jp2");
B5URL = strrep(B4URL,"B04.jp2","B05.jp2");
B8URL = strrep(B4URL,"B04.jp2","B08.jp2");
B12URL = strrep(B4URL,"B04.jp2","B12.jp2");
TCIURL = strrep(B4URL,"B04.jp2","TCI.jp2");
%download images
%wait_t = randi(10)
%pause(wait_t)
try
	urlwrite(B2URL, 'Tile_B02.jp2');
	wait_t = randi(5)
	pause(wait_t)
        urlwrite(B3URL, 'Tile_B03.jp2');
	wait_t = randi(5)
        pause(wait_t)
        urlwrite(B4URL, 'Tile_B04.jp2');
	wait_t = randi(5)
        pause(wait_t)
        urlwrite(B5URL, 'Tile_B05.jp2');
	wait_t = randi(5)
        pause(wait_t)
        urlwrite(B8URL, 'Tile_B08.jp2');
	wait_t = randi(5)
        pause(wait_t)
        urlwrite(B12URL, 'Tile_B12.jp2');
	wait_t = randi(5)
        pause(wait_t)
        urlwrite(TCIURL, 'Tile_TCI.jp2');
	B2 = imread('Tile_B02.jp2');
	B3 = imread('Tile_B03.jp2');
	B4 = imread('Tile_B04.jp2');
	B5 = imread('Tile_B05.jp2');
	B8 = imread('Tile_B08.jp2');
	B12 = imread('Tile_B12.jp2');
	TCI = imread('Tile_TCI.jp2');
	imwrite(TCI,'Tile_TCI.png');
		
	imwrite(B2,'Tile_B02.png');
	imwrite(B3,'Tile_B03.png');
	imwrite(B4,'Tile_B04.png');
	imwrite(B5,'Tile_B05.png');
	imwrite(B8,'Tile_B08.png');
	imwrite(B12,'Tile_B12.png');
%	imageData = imread(imgFileName);
	imageData = 'done'
	return
catch
        imageData = 'failed due to HTTP Error'
%        imageData = strcat(UID,"failed4")
        return
end
end

