OnMouseExit triggering when its not supposed to

I’m currently designing my main menu, basically I’m trying to make it so when the mouse hovers over a button, it will play one animation, then move to another looping animation. (yes i have loop time turned on and off respectively) then when the mouse moves away from the button it plays an animation and returns to it’s original state.

but for some reason, while the mouse is over the button it continually changes the bool that tells it weather or not the mouse is over it, so it just cycles through all the animations over and over until i move the mouse away.

here’s my code

private void OnMouseOver()
{
    if (buttonSelected == false)
    {
        myAnimator.SetBool("IsSelected", true);
        buttonSelected = true;
    }
    else
    {
        return;
    }
}

private void OnMouseExit()
{
    if (buttonSelected == true)
    {
        myAnimator.SetBool("IsSelected", false);
        buttonSelected = false;
    }
    else
    {
        return;
    }
}

,

well, I figured out a fix. rather than use the OnMouseOver and Exit methods, i changed them to two public methods and used the event trigger component with onPointerEnter and OnPointerExit