fixed #194 and added stream code