Version where streaming works... Now focusing on the main algorithm...