Implemented pack function