refactor util.js