Tidied up le JavaScript