Tidied js code