Tidied up Code