moved js code to main.js