function result_status = download_tiles(JSONString)

pkg load image
JSONSentinel = JSONString
B4URL = JSONSentinel.Band4URI
%TileCloudCover = str2double(JSONSentinel.cloud_cover)
FieldArea = JSONSentinel.FieldArea
UID = JSONSentinel.UID
B8URL = strrep(B4URL,"B04.jp2","B08.jp2")
B12URL = strrep(B4URL,"B04.jp2","B12.jp2")

TCIURL = strrep(B4URL,"B04.jp2","TCI.jp2")
B5URL = strrep(B4URL,"B04.jp2","B05.jp2")
B2URL = strrep(B4URL,"B04.jp2","B02.jp2")
B3URL = strrep(B4URL,"B04.jp2","B03.jp2")
B4FileName = 'Tile_B4.jp2';

B8FileName = 'Tile_B8.jp2';
TCIFileName = 'Tile_TCI.jp2';

B12FileName = 'Tile_B12.jp2';
B5FileName = 'TIle_B5.jp2';

B2FileName = 'Tile_B2.jp2';

B3FileName = 'Tile_B3.jp2';

try
                urlwrite(B4URL,B4FileName);

                wait_t = randi(10)
                pause(wait_t)

                urlwrite(B8URL,B8FileName);

                wait_t = randi(10)
                pause(wait_t)

                urlwrite(TCIURL,TCIFileName);

                wait_t = randi(10)
                pause(wait_t)

                urlwrite(B12URL,B12FileName);

                wait_t = randi(10)
                pause(wait_t)

                %urlwrite(B8AURL,B8AFileName);
                %wait_t = randi(10)
                %pause(wait_t)

                urlwrite(B5URL,B5FileName);

                wait_t = randi(10)
                pause(wait_t)

                urlwrite(B2URL,B2FileName);
                wait_t = randi(10)
                pause(wait_t)
		urlwrite(B3URL,B3FileName);
		result_status = 'done'
        catch
                down = 'failed due to HTTP Error'
                result_status = strcat(UID,"failed4")
                return
        end
end
