tidied up the code
tidied up the code for functions