Changed implementation in order to use Streams.