Tidied up js