improved script to get image link