Moved functions out of main script into functions.js
Moved functions out of main script into functions.js