tidied up functions and added scipt and command files