Replace duplicate code with call to removeChild