Moved helper functions into helpers.js