Tidied up the code - removed a function