added image loading logic