changed packet packing routine