Nightwatch: Unable to get the updated array value in the assertion

Using Nightwatch with JS. Below is the Page object which I am using. Under commands, I initialized an empty array, “deletedPlans”. Then further in the code, I’m pushing values to it. In the end, in the assertion, I am trying to print the updated array value in the message, but it prints nothing, taking the array value as empty. Whereas, inside the function where I’ve commented, it prints the array value perfectly. What wrong I am doing?

module.exports = {
url:'/xyz',

elements: {     
    deleteAction:{
        selector: '//span[text()="Delete"]',
        locateStrategy: 'xpath'
    },
    PlanTitleVerify:{
        //some selector
    }
},

commands:[{

    deletePlan: async function (browser){

            var myPage = this
            var deletedPlans =[]
            
            browser 
                .elements('xpath', '//div[@class="ant-card-head-title"]//span', function (elements) {
      
                    elements.value.forEach(element => {
                        let key = Object.keys(element)[0];
                        let ElementIDvalue = element[key];
      
                        browser.elementIdText(ElementIDvalue, function (result) {    
                        let planName = result.value
                        deletedPlans.push(planName) //Adding value to the Array
                
                        console.log("Plan to be deleted:" + deletedPlans) //Here value gets printed      
                    
                        myPage
                          .pause(2000)
                          .click('@deleteAction')
                        })         
                    })           
                })

            myPage.assert.not.elementPresent('@PlanTitleVerify', 'Deleted plans are:' + deletedPlans) //Here value is blank
    },
  }]
};