JS update

Updates to the JS file with logic and additional functions