implementing preload for loadJSON and loadImage