refactoring and debugging of existing pckge auto-packing