refact, use buffer instead of packet structure