Refactored listing code