Tidied the code a littlebit