moved function to util.js