updating the loading function to trigger only after the main image has loaded