refactoring with stream API