trim code
update for stream