better code for stream