refactoring packet parser