Refactoring of fib_stream function