tidied up js