Moralis.onAccountsChanged error

I want to perform some action on account change but the function keeps running for like 10 times

Moralis.onAccountsChanged(async (accounts) => {
    //const confirmed = confirm("Link this address to your account?");
    //if (confirmed) {
    //  await[0]);

this would log the address for like 10 times

I don’t know why it does that, but you could keep a variable for previous address and run some code only when you see a different address compared to the previous address