tidied up factory