Use .remove() function instead of .parent.removeChild()