util.js refactored.