tidied up setupAndClean code