STREAMS-197 | add util function and refactored