updated controller and created a factory