Rewrite to use streaming, rather than block on input