refactor stream api