check for img element before removing it