updating cost function and camera functions