Tidied the code