Refactored code around listing output