add refinements for stream functions to track length