refactor packet