Refactored code to use the helper method mapToList() instead of the Collectors call.