refactor Transformer.transform method to use stream API.