code cleanup of util.js