refactor to use destructuring assignment