fix bugs for first packet