updated, corrected version of split_stream.m