better handling of the image loading