split code into `util.js`