Updated functions.js