Move js code to the .js file