fixed loadImage function