Javascript logic moved into static js file