refactored code to destructively mutate the list in place and then return it through the callback