Adds protection in case imageURLIndex is out of bonds in imagesRanges