IsPointerOverGameObject not working with multiple instances

Hi all,
I’m working on a menu which is brought up by holding down the mouse, and the player selects an element by releasing the mouse button while hovering over a certain element. Right now each element in the menu is an Image on a canvas. Each image has an instance of a script which has the following snippet of code:

private void OnDisable()
    {
        if (EventSystem.current.IsPointerOverGameObject())
        {
            print(this.name + " selected");
        }

    }

However, when I test this in Unity every single instance of the script responds and prints its name (even though clearly the mouse can only be in one spot at a time). Is using IsPointerOverGameObject() the wrong approach to this problem? Or am I doing something wrong?

Many thanks!

I figured it out!
I added two functions to my script to toggle a variable mouseOver, and added an event trigger to each image to call these functions. Then I replaced the conditional in the above code with if(mouseOver), and everything is working as desired!