Tidied up  code in the scripts.js