complete. tidied up comments and spacing