refactor to Stream module