modified get_img function