Added function to save image history
Also changed the location of the variable declaration that prevents the user from retrieving an image to stop rapid image retrieval issues