Use Stream module functions to avoid intermediate lists