Tidied up script and added more comments tlee