move js code to functions.js