new algo based on stream