refactoring do_extract_streams