refactor using stream2