add support for stream api instead of foreach