tidied up factory and controller