refactor StreamParser