removeChild but don't know where or how

I keep getting this Error

RangeError: Error #2006: The supplied index is out of bounds.
at flash.display::DisplayObjectContainer/addChildAt()
at stage_fla::MainTimeline/frame2()
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at navbar_fla::MainTimeline/frame1()

And have come to the conclusion that I need to use a removeChild() in my code from what I have been reading. Problem is I don’t know where to do that.

var imageRequest:URLRequest = new URLRequest("navbar.swf");
var navbar_mc:Loader = new Loader();
var externalSwf:Object;
navbar_mc.load(imageRequest);
addChild(navbar_mc);
addChildAt(this.navbar_mc, 4);
navbar_mc.addEventListener(Event.COMPLETE, grabContent);

function grabContent(event:Event):void
{
   externalSwf = event.target.content;
   nextFunction();
}
 
function nextFunction():void
{
   externalSwf.childMethod();
   externalSwf.someProperty = 15;
}

How do I write the removeChild in so that this error stops popping up? The swf works fine I just want to make sure there are no errors just in case.