Creating a close function, not sure why its not working

Ok posting one last thing today.
I’m creating a close function, basically it removes the display box, and the text, if it detects its not null. Though when i remove any text other than the text1 I’m getting a null object error.

heres the code


function exit(event:MouseEvent):void


{
    removeChild(mc_x)
    removeChild(dpBox)
    timer1.stop()
    timer2.stop()
    timer3.stop()
    
    
    {
    if(text1 != null)
    {
                text1.parent.removeChild(text1)

    }
    else if(text2 != null)
    {
                text2.parent.removeChild(text2)

    }
    else if(text3 != null)
            {
                text3.parent.removeChild(text3)

            }
            
                                else
                                {
                                }

            
    }
            

    

}