add packet
improve code