Added support for removing earlier images when calling function again