change the position of image loading code