update controller and factory, improve code quality