refactoring pack.js