incorporated the review changes and optimized the old_images_query