refactor code using fzaninotto/Streamer