fixing TypeError in controller