restructured code, new functions.js