moved js code to seperate js file