Refactor listener for readability