Refactor to remove 'Arrow Anti-pattern'
Remove unused global variable not used in this function.