refactored to use stream API