rewrite of stream macro