Streams 164

It seems like this block of logic is being used in more than one place. Do you think it could be abstracted elsewhere?