little refactoring
stable for bad packets