Updated script for image loading