trying to speed up gen_pkt