fix bug in packing