added parentNode check for removal