Play two Animations

I have the following code setup so that when I click on my door it plays the animation that is on it the problem lies in the fact that I would like two animations. One for opening the door and one for closing the door. But if the door is already open I don’t want it to play the open animation again, I want it to play the close animation.

Here is my code:

 void OnMouseDown() 
	{
      animation.Play();   
    }

Something like this should work.

private bool isOpen = false;

void OnMouseDown() {
    if(!animation.IsPlaying("open") && !animation.IsPlaying("close")) {
        if(isOpen)
            animation.Play("close");
 
        else
           animation.Play("open");

        isOpen = !isOpen;
    }
}