move code to ccontroller object