update functions.js from edmonca