fixed the pack function