refactoring cookies stream parser