Move utility functions to util.js