Moved scripts to a js file