tidied up code.