updated
tidied up javascript code